StocksNew/app/Models/User.php
Sampanna Rimal 53c0140f58 first commit
2024-08-27 17:48:06 +05:45

63 lines
1.4 KiB
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 Modules\Employee\Models\Employee;
use Spatie\Permission\Traits\HasPermissions;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable, HasRoles, HasPermissions;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'employee_id',
'remember_token',
];
/**
* 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',
];
protected $appends = ['full_name', 'profile_pic'];
public function employee()
{
return $this->belongsTo(Employee::class, 'employee_id');
}
protected function getProfilePicAttribute()
{
return $this->employee ? asset('storage/' . $this->employee?->profile_picture) : asset('assets/images/task.png');
}
}