dealhub/app/Models/User.php
kusowl 1275a74506 feat: broker profile
- add morph to relationship
- add profile markup
- modify page-heading.blade.php to accept center and end sections
2026-01-13 18:06:27 +05:30

73 lines
1.5 KiB
PHP

<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Enums\UserTypes;
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->role === UserTypes::Broker->value;
}
public function deals(): HasMany
{
return $this->hasMany(Deal::class);
}
/**
* Returns model of User's type
*/
public function type(): MorphTo
{
return $this->morphTo();
}
}