ldc-flucollector/app/Models/User.php

64 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2021-11-19 11:00:00 +01:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
2022-04-06 10:36:10 +02:00
use Illuminate\Support\Facades\Hash;
2021-11-19 11:00:00 +01:00
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens;
use HasFactory;
use Notifiable;
2021-11-19 11:00:00 +01:00
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
2022-04-06 10:36:10 +02:00
/**
* Perform any actions required after the model boots.
*
* @return void
*/
protected static function booted()
{
static::creating(function (self $user) {
$user->password = Hash::make($user->password);
});
static::updating(function (self $user) {
if (Hash::needsRehash($user->password)) {
$user->password = Hash::make($user->password);
}
});
}
2021-11-19 11:00:00 +01:00
}