añadir nuevas funcionalidades
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled

This commit is contained in:
2025-04-30 20:56:28 +02:00
parent 883daf32ed
commit f97a7a8498
27 changed files with 2359 additions and 875 deletions

View File

@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Spatie\Permission\Traits\HasRoles;
@@ -21,9 +22,18 @@ class User extends Authenticatable
* @var list<string>
*/
protected $fillable = [
'name',
'title',
'first_name',
'last_name',
'username',
'email',
'password',
'phone',
'address',
'access_start',
'access_end',
'is_active',
'profile_photo_path',
];
/**
@@ -39,26 +49,25 @@ class User extends Authenticatable
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
* @var list<string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'is_protected' => 'boolean',
];
}
protected $casts = [
'email_verified_at' => 'datetime',
'access_start' => 'date',
'access_end' => 'date',
'is_active' => 'boolean'
];
/**
* Get the user's initials
*/
public function initials(): string
{
return Str::of($this->name)
/*return Str::of($this->name)
->explode(' ')
->map(fn (string $name) => Str::of($name)->substr(0, 1))
->implode('');
->implode('');*/
return Str::of('');
}
public function groups()
@@ -89,5 +98,16 @@ class User extends Authenticatable
return $group->hasAnyPermission($permissions);
});
}
public function getFullNameAttribute()
{
return "{$this->title} {$this->first_name} {$this->last_name}";
}
// Accesor para la URL completa
public function getProfilePhotoUrlAttribute()
{
return $this->profile_photo ? Storage::url($this->profile_photo) : asset('images/default-user.png');
}
}