167 lines
5.7 KiB
PHP
167 lines
5.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
* Date: Thu, 21 Mar 2019 13:39:44 +0100.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\Util;
|
|
use Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class TravelUser
|
|
*
|
|
* @property int $id
|
|
* @property int $salutation_id
|
|
* @property string $title
|
|
* @property string $first_name
|
|
* @property string $last_name
|
|
* @property string $email
|
|
* @property string $password
|
|
* @property string $company
|
|
* @property string $street
|
|
* @property string $zipcode
|
|
* @property string $city
|
|
* @property string $phone
|
|
* @property string $mobil
|
|
* @property string $fax
|
|
* @property \Carbon\Carbon $birthday
|
|
* @property int $travel_nationality_id
|
|
* @property string $last_user_data
|
|
* @property \Carbon\Carbon $created_at
|
|
* @property \Carbon\Carbon $updated_at
|
|
* @property string $deleted_at
|
|
* @property \App\Models\TravelNationality $travel_nationality
|
|
* @property \Illuminate\Database\Eloquent\Collection $travel_user_booking_fewos
|
|
* @package App\Models
|
|
* @method static bool|null forceDelete()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\TravelUser onlyTrashed()
|
|
* @method static bool|null restore()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\TravelUser withTrashed()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\TravelUser withoutTrashed()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereBirthday($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereCity($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereCompany($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereDeletedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereEmail($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereFax($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereFirstName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereLastName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereLastUserData($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereMobil($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser wherePassword($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser wherePhone($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereSalutationId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereStreet($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereTitle($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereTravelNationalityId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUser whereZipcode($value)
|
|
* @property-read int|null $travel_user_booking_fewos_count
|
|
* @mixin \Eloquent
|
|
*/
|
|
class TravelUser extends Model
|
|
{
|
|
use \Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
protected $connection = 'mysql_stern';
|
|
|
|
protected $table = 'travel_users';
|
|
|
|
protected $casts = [
|
|
'salutation_id' => 'int',
|
|
'travel_nationality_id' => 'int',
|
|
'last_user_data' => 'array'
|
|
];
|
|
|
|
protected $dates = [
|
|
'birthday'
|
|
];
|
|
|
|
protected $hidden = [
|
|
'password'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'salutation_id',
|
|
'title',
|
|
'first_name',
|
|
'last_name',
|
|
'email',
|
|
'password',
|
|
'company',
|
|
'street',
|
|
'zipcode',
|
|
'city',
|
|
'phone',
|
|
'mobil',
|
|
'fax',
|
|
'birthday',
|
|
'travel_nationality_id',
|
|
'last_user_data'
|
|
];
|
|
|
|
public static $salutationType = [
|
|
1 => 'Herr',
|
|
2 => 'Frau',
|
|
3 => 'Divers/keine Anrede',
|
|
4 => 'Firma'
|
|
];
|
|
|
|
public static $salutationNameType = [
|
|
1 => 'Herr',
|
|
2 => 'Frau',
|
|
3 => '',
|
|
4 => 'Firma'
|
|
];
|
|
|
|
public static $salutationDearType = [
|
|
1 => 'geehrter',
|
|
2 => 'geehrte',
|
|
3 => 'geehrte:r',
|
|
4 => ''
|
|
];
|
|
|
|
public function travel_nationality()
|
|
{
|
|
return $this->belongsTo(\App\Models\TravelNationality::class);
|
|
}
|
|
|
|
public function travel_user_booking_fewos()
|
|
{
|
|
return $this->hasMany(\App\Models\TravelUserBookingFewo::class);
|
|
}
|
|
|
|
|
|
public function getBirthdayAttribute($value)
|
|
{
|
|
if(!$value){
|
|
return "";
|
|
}
|
|
return Carbon::parse($value)->format(Util::formatDateDB());
|
|
}
|
|
|
|
public function setBirthdayAttribute( $value ) {
|
|
$this->attributes['birthday'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
|
}
|
|
|
|
public function getSalutation(){
|
|
return isset(self::$salutationType[$this->salutation_id]) ? self::$salutationType[$this->salutation_id] : '';
|
|
}
|
|
|
|
public function getSalutationName(){
|
|
return isset(self::$salutationNameType[$this->salutation_id]) ? self::$salutationNameType[$this->salutation_id] : '';
|
|
}
|
|
|
|
public function getSalutationDear(){
|
|
return isset(self::$salutationDearType[$this->salutation_id]) ? self::$salutationDearType[$this->salutation_id] : '';
|
|
}
|
|
}
|