ldc-com-app-bo/app/Models/User.php
2026-10-22 16:17:56 +02:00

80 lines
2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use App\Enums\UserRolesEnum;
/**
* @property integer $first_name User first name.
* @property string $last_name User last name.
* @property string $email User email.
* @property \App\Enums\UserRolesEnum $role User role.
* @property \Carbon\Carbon $last_connection Last connection date.
* @property-read \Carbon\Carbon $created_at Created date.
* @property-read \Carbon\Carbon $updated_at Updated date.
*/
class User extends Authenticatable
{
use HasFactory;
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'first_name',
'last_name',
'email',
'last_connection',
'role',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'last_connection' => 'datetime',
'role' => UserRolesEnum::class
];
// * METHODS.
/**
* Get the password for the user.
*
* @return string
*/
public function getAuthPassword(): string
{
return '';
}
// * RELATIONSHIPS
/**
* MorphToMany directories relation.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
*/
public function directories(): \Illuminate\Database\Eloquent\Relations\MorphToMany
{
return $this->morphToMany(Directory::class, 'directorables');
}
/**
* The tenants that belong to the user.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function tenants(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Tenant::class);
}
}