añadir nuevas funcionalidades
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user