mein-sterntours/app/Models/Customer.php
2020-04-15 12:11:42 +02:00

160 lines
5.8 KiB
PHP

<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class Customer
*
* @property int $id
* @property int $salutation_id
* @property string $title
* @property string $name
* @property string $firstname
* @property Carbon $birthdate
* @property string $company
* @property string $street
* @property string $zip
* @property string $city
* @property string $email
* @property string $phone
* @property string $phonebusiness
* @property string $phonemobile
* @property string $fax
* @property string $bank
* @property string $bank_code
* @property string $bank_account_number
* @property int $credit_card_type_id
* @property string $credit_card_number
* @property Carbon $credit_card_expiration_date
* @property string $participants_remarks
* @property string $miscellaneous_remarks
* @property Carbon $created_at
* @property Carbon $updated_at
* @property int $country_id
* @property TravelCountry $travel_country
* @property CreditCardType $credit_card_type
* @property Salutation $salutation
* @property Collection|Booking[] $bookings
* @property Collection|Coupon[] $coupons
* @property Collection|Lead[] $leads
* @package App\Models
* @property-read int|null $bookings_count
* @property-read int|null $coupons_count
* @property-read int|null $leads_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereBank($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereBankAccountNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereBankCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereBirthdate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereCity($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereCompany($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereCountryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereCreditCardExpirationDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereCreditCardNumber($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereCreditCardTypeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereEmail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereFax($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereFirstname($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereMiscellaneousRemarks($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereParticipantsRemarks($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer wherePhone($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer wherePhonebusiness($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer wherePhonemobile($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereSalutationId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereStreet($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Customer whereZip($value)
* @mixin \Eloquent
*/
class Customer extends Model
{
protected $connection = 'mysql';
protected $table = 'customer';
protected $casts = [
'salutation_id' => 'int',
'credit_card_type_id' => 'int',
'country_id' => 'int'
];
protected $dates = [
'birthdate',
'credit_card_expiration_date'
];
protected $fillable = [
'salutation_id',
'title',
'name',
'firstname',
'birthdate',
'company',
'street',
'zip',
'city',
'email',
'phone',
'phonebusiness',
'phonemobile',
'fax',
'bank',
'bank_code',
'bank_account_number',
'credit_card_type_id',
'credit_card_number',
'credit_card_expiration_date',
'participants_remarks',
'miscellaneous_remarks',
'country_id',
];
public function travel_country()
{
return $this->belongsTo(TravelCountry::class, 'country_id');
}
public function credit_card_type()
{
return $this->belongsTo(CreditCardType::class);
}
public function salutation()
{
return $this->belongsTo(Salutation::class);
}
public function bookings()
{
return $this->hasMany(Booking::class);
}
public function coupons()
{
return $this->hasMany(Coupon::class);
}
public function leads()
{
return $this->hasMany(Lead::class);
}
public function fullName()
{
if ($this->firstname) {
return $this->firstname . ' ' . $this->name;
}
return $this->name;
}
}