75 lines
1.7 KiB
PHP
Executable File
75 lines
1.7 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Notifications\ResetPasswordMail;
|
|
use App\Notifications\VerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
|
|
class User extends Authenticatable implements MustVerifyEmail
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable;
|
|
use HasRoles;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->guarded = [
|
|
//'password',
|
|
//'email',
|
|
'remember_token'
|
|
];
|
|
$this->hidden = [
|
|
'password',
|
|
'remember_token'
|
|
];
|
|
$this->casts = [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
$this->appends = [
|
|
'path_avatar'
|
|
];
|
|
}
|
|
|
|
public function getPathAvatarAttribute()
|
|
{
|
|
if (!empty($this->avatar)) {
|
|
return asset('/storage/' . $this->avatar);
|
|
}
|
|
|
|
return asset('img/avatar.png');
|
|
}
|
|
/**
|
|
* Send the password reset notification.
|
|
*
|
|
* @param string $token
|
|
* @return void
|
|
*/
|
|
public function sendPasswordResetNotification($token)
|
|
{
|
|
$this->notify(new ResetPasswordMail($token));
|
|
}
|
|
|
|
public function sendEmailVerificationNotification()
|
|
{
|
|
$this->notify(new VerifyEmail($this));
|
|
}
|
|
}
|