dealhub/app/Models/User.php
kusowl 985dd967e4 feature(search deals)
- make deals reachable
- add recent search feature
- add animation in profile menu
- refactor blade markup of explore page
2026-01-20 18:43:13 +05:30

82 lines
1.7 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
'status',
'role',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
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);
}
}