Preview: User.php
Size: 1.42 KB
/home/byroehnu/easetack.com/app/Models/User.php
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements MustVerifyEmail
{
use HasApiTokens, HasFactory, HasRoles, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'id',
'name',
'email',
'password',
'about',
'provider_id',
'provider',
];
protected $appends = ['role_name', 'role_title'];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
/**
* Get users role name
*/
public function getRoleNameAttribute(): mixed
{
return $this->roles->first()?->name;
}
/**
* Get users role title
*/
public function getRoleTitleAttribute(): mixed
{
return $this->roles->first()?->title;
}
}
Directory Contents
Dirs: 0 × Files: 50