97 lines
3.1 KiB
PHP
97 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Carbon\Carbon;
|
|
|
|
|
|
/**
|
|
* App\Models\UserAccount
|
|
*
|
|
* @property-read \App\Models\Country $company_country
|
|
* @property-read \App\Models\Country $company_pre_phone
|
|
* @property-read \App\Models\Country $country
|
|
* @property mixed $birthday
|
|
* @property-read mixed $company
|
|
* @property-read \App\Models\Country $pre_mobil
|
|
* @property-read \App\Models\Country $pre_phone
|
|
* @property-read \App\User $user
|
|
* @method static bool|null forceDelete()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount newQuery()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount onlyTrashed()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount query()
|
|
* @method static bool|null restore()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount withTrashed()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount withoutTrashed()
|
|
* @mixin \Eloquent
|
|
*/
|
|
class UserAccount extends Model
|
|
{
|
|
protected $table = 'user_accounts';
|
|
|
|
|
|
protected $fillable = [
|
|
'company', 'salutation', 'first_name', 'last_name', 'address', 'address_2', 'zipcode', 'city', 'country_id', 'pre_phone_id', 'phone', 'pre_mobil_id', 'mobil',
|
|
'tax_number', 'tax_identification_number', 'same_as_billing',
|
|
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_pre_phone_id', 'shipping_phone',
|
|
'birthday', 'website', 'facebook', 'facebook_fanpage', 'instagram'
|
|
];
|
|
|
|
use SoftDeletes;
|
|
protected $dates = ['deleted_at'];
|
|
|
|
|
|
public function user()
|
|
{
|
|
return $this->hasOne('App\User', 'account_id');
|
|
}
|
|
|
|
public function country()
|
|
{
|
|
return $this->belongsTo('App\Models\Country', 'country_id');
|
|
}
|
|
|
|
public function shipping_country()
|
|
{
|
|
return $this->belongsTo('App\Models\Country', 'shipping_country_id');
|
|
}
|
|
|
|
public function pre_phone()
|
|
{
|
|
return $this->belongsTo('App\Models\Country', 'pre_phone_id');
|
|
}
|
|
|
|
public function pre_mobil()
|
|
{
|
|
return $this->belongsTo('App\Models\Country', 'pre_mobil_id');
|
|
}
|
|
|
|
public function shipping_pre_phone()
|
|
{
|
|
return $this->belongsTo('App\Models\Country', 'shipping_pre_phone_id');
|
|
}
|
|
|
|
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 getDataProtectionFormat(){
|
|
if(!$this->attributes['data_protection']){ return ""; }
|
|
return Carbon::parse($this->attributes['data_protection'])->format(\Util::formatDateTimeDB());
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|