Files
Caramel-CRM/app/Models/User.php
T

70 lines
1.5 KiB
PHP
Raw Normal View History

2025-10-20 08:57:51 +02:00
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Laravel\Sanctum\HasApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, HasApiTokens, Notifiable, TwoFactorAuthenticatable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
'avatar', // Add avatar field
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
2026-02-17 10:35:03 +01:00
'two_factor_secret',
'two_factor_recovery_codes',
'two_factor_confirmed_at',
2025-10-20 08:57:51 +02:00
];
2026-02-17 10:35:03 +01:00
2025-10-20 08:57:51 +02:00
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
/**
* Get the URL to the user's avatar.
*/
public function getAvatarUrlAttribute()
{
if ($this->avatar) {
return asset('storage/' . $this->avatar);
}
// Return null if no avatar is set
return null;
}
}