*/ use HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'email', 'password', 'status', 'role', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } public function isBroker(): bool { return $this->type instanceof Broker; } public function deals(): HasMany { return $this->hasMany(Deal::class); } /** * Returns model of User's role type */ public function type(): MorphTo { return $this->morphTo('role'); } public function interactions(): HasMany { return $this->hasMany(User::class); } public function recentSearches(): HasMany { return $this->hasMany(RecentSearch::class); } public function isCustomer(): bool { return $this->type instanceof Customer; } public function dealsInteractions(): HasManyThrough { return $this->hasManyThrough(Interaction::class, Deal::class); } public function interactedDeals(): HasManyThrough { return $this->hasManyThrough(Deal::class, Interaction::class, 'user_id', 'id', 'id', 'deal_id'); } public function reports(): HasMany { return $this->hasMany(Report::class); } }