'timestamp', 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', 'last_login' => 'timestamp', ]; protected $hidden = [ 'password', 'remember_token', 'user_id', 'company_id', 'client_id', 'google_2fa_secret', 'id', 'oauth_provider_id', 'oauth_user_id', 'token', ]; protected $fillable = [ 'first_name', 'last_name', 'phone', 'custom_value1', 'custom_value2', 'custom_value3', 'custom_value4', 'email', 'is_primary', 'client_id', ]; public function getEntityType() { return self::class; } public function getHashedIdAttribute() { return $this->encodePrimaryKey($this->id); } /**/ public function getRouteKeyName() { return 'contact_id'; } public function getContactIdAttribute() { return $this->encodePrimaryKey($this->id); } public function setAvatarAttribute($value) { if (! filter_var($value, FILTER_VALIDATE_URL) && $value) { $this->attributes['avatar'] = url('/').$value; } else { $this->attributes['avatar'] = $value; } } public function client() { return $this->belongsTo(Client::class)->withTrashed(); } public function primary_contact() { return $this->where('is_primary', true); } public function company() { return $this->belongsTo(Company::class); } public function user() { return $this->belongsTo(User::class)->withTrashed(); } public function invoice_invitations() { return $this->hasMany(InvoiceInvitation::class); } public function quote_invitations() { return $this->hasMany(QuoteInvitation::class); } public function credit_invitations() { return $this->hasMany(CreditInvitation::class); } public function sendPasswordResetNotification($token) { $this->notify(new ClientContactResetPassword($token)); } public function preferredLocale() { $languages = Cache::get('languages'); return $languages->filter(function ($item) { return $item->id == $this->client->getSetting('language_id'); })->first()->locale; } public function routeNotificationForMail($notification) { return $this->email; } /** * Retrieve the model for a bound value. * * @param mixed $value * @return \Illuminate\Database\Eloquent\Model|null */ public function resolveRouteBinding($value, $field = NULL) { return $this ->withTrashed() ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); } /** * @return mixed|string */ public function avatar() { if ($this->avatar) { return $this->avatar; } return asset('images/svg/user.svg'); } }