2023-03-14 14:57:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
2023-07-13 08:34:54 +00:00
|
|
|
use App\Enums\UserRolesEnum;
|
2023-03-14 14:57:03 +01:00
|
|
|
|
2025-05-20 10:16:12 +02:00
|
|
|
/**
|
2025-05-26 11:33:47 +02:00
|
|
|
* @property integer $first_name User first name.
|
|
|
|
|
* @property string $last_name User last name.
|
2025-05-20 10:16:12 +02:00
|
|
|
* @property string $email User email.
|
|
|
|
|
* @property \App\Enums\UserRolesEnum $role User role.
|
2025-05-26 11:33:47 +02:00
|
|
|
* @property \Carbon\Carbon $last_connection Last connection date.
|
2025-05-20 10:16:12 +02:00
|
|
|
* @property-read \Carbon\Carbon $created_at Created date.
|
|
|
|
|
* @property-read \Carbon\Carbon $updated_at Updated date.
|
|
|
|
|
*/
|
2023-03-14 14:57:03 +01:00
|
|
|
class User extends Authenticatable
|
|
|
|
|
{
|
|
|
|
|
use HasFactory;
|
|
|
|
|
use Notifiable;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
2025-05-20 10:16:12 +02:00
|
|
|
* @var list<string>
|
2023-03-14 14:57:03 +01:00
|
|
|
*/
|
|
|
|
|
protected $fillable = [
|
2025-05-26 11:33:47 +02:00
|
|
|
'first_name',
|
|
|
|
|
'last_name',
|
2023-03-14 14:57:03 +01:00
|
|
|
'email',
|
2025-05-26 11:33:47 +02:00
|
|
|
'last_connection',
|
2025-05-20 16:20:23 +02:00
|
|
|
'role',
|
2023-03-14 14:57:03 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that should be cast.
|
|
|
|
|
*
|
|
|
|
|
* @var array<string, string>
|
|
|
|
|
*/
|
|
|
|
|
protected $casts = [
|
2025-05-26 11:33:47 +02:00
|
|
|
'last_connection' => 'datetime',
|
|
|
|
|
'role' => UserRolesEnum::class
|
2023-07-13 08:34:54 +00:00
|
|
|
];
|
|
|
|
|
|
2026-10-20 16:03:44 +02:00
|
|
|
// * METHODS.
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the password for the user.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getAuthPassword(): string
|
|
|
|
|
{
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-26 11:33:47 +02:00
|
|
|
// * RELATIONSHIPS
|
2023-07-25 12:55:22 +02:00
|
|
|
|
|
|
|
|
/**
|
2025-05-26 11:33:47 +02:00
|
|
|
* MorphToMany directories relation.
|
2023-07-25 12:55:22 +02:00
|
|
|
*
|
2025-05-26 11:33:47 +02:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
|
2023-07-25 12:55:22 +02:00
|
|
|
*/
|
2025-05-26 11:33:47 +02:00
|
|
|
public function directories(): \Illuminate\Database\Eloquent\Relations\MorphToMany
|
2023-07-25 12:55:22 +02:00
|
|
|
{
|
2025-05-26 11:33:47 +02:00
|
|
|
return $this->morphToMany(Directory::class, 'directorables');
|
2023-07-25 12:55:22 +02:00
|
|
|
}
|
2023-08-21 17:12:26 +02:00
|
|
|
|
2023-07-21 14:51:02 +02:00
|
|
|
/**
|
2025-05-26 11:33:47 +02:00
|
|
|
* The tenants that belong to the user.
|
2023-07-21 14:51:02 +02:00
|
|
|
*
|
2025-05-26 11:33:47 +02:00
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
2023-07-21 14:51:02 +02:00
|
|
|
*/
|
2025-05-26 11:33:47 +02:00
|
|
|
public function tenants(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
2023-07-21 14:51:02 +02:00
|
|
|
{
|
2025-05-26 11:33:47 +02:00
|
|
|
return $this->belongsToMany(Tenant::class);
|
2023-07-21 14:51:02 +02:00
|
|
|
}
|
2023-03-14 14:57:03 +01:00
|
|
|
}
|