'array', 'notice' => 'array', //'reverse_charge' => 'bool' ]; 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()); } public function getAcceptContractFormat() { if (!$this->attributes['accept_contract']) { return ""; } return Carbon::parse($this->attributes['accept_contract'])->format(\Util::formatDateTimeDB()); } public function getReverseChargeValidFormat() { if (!$this->attributes['reverse_charge_valid']) { return ""; } return Carbon::parse($this->attributes['reverse_charge_valid'])->format(\Util::formatDateTimeDB()); } public function getCountryAttrAs($attr, $as = false) { if ($this->country) { $val = $this->country->getAttrByKey($attr); if ($val) { if ($as) { return $as; } return true; } } return ""; } public function setNotice($key, $value) { $notice = $this->notice; $notice[$key] = $value; $this->notice = $notice; $this->save(); } public function getNotice($key) { return isset($this->notice[$key]) ? $this->notice[$key] : false; } public function getPhoneNumber() { if ($this->mobil && $this->mobil !== "") { return ($this->pre_mobil ? $this->pre_mobil->phone : '') . " " . $this->mobil; } if ($this->phone && $this->phone !== "") { return ($this->pre_phone ? $this->pre_phone->phone : '') . " " . $this->phone; } } public function getPhoneFull() { if ($this->phone && $this->phone !== "") { return ($this->pre_phone ? $this->pre_phone->phone : '') . " " . $this->phone; } return ""; } public function getMobilFull() { if ($this->mobil && $this->mobil !== "") { return ($this->pre_mobil ? $this->pre_mobil->phone : '') . " " . $this->mobil; } return ""; } public function getShippingPhoneFull() { if ($this->shipping_phone && $this->shipping_phone !== "") { return ($this->shipping_pre_phone ? $this->shipping_pre_phone->phone : '') . " " . $this->shipping_phone; } return ""; } }