ldc-web/app/Models/User.php

66 lines
1.4 KiB
PHP
Raw Normal View History

2020-04-09 13:05:23 +02:00
<?php
2022-09-21 11:17:58 +00:00
namespace App\Models;
2020-04-09 13:05:23 +02:00
2023-09-22 09:59:11 +02:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
2020-04-09 13:05:23 +02:00
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
2023-09-22 09:59:11 +02:00
use Illuminate\Support\Facades\Hash;
2020-04-09 13:05:23 +02:00
class User extends Authenticatable
{
2023-09-22 09:59:11 +02:00
use HasFactory;
2020-04-09 13:05:23 +02:00
use Notifiable;
/**
* The attributes that are mass assignable.
*
2023-09-22 09:59:11 +02:00
* @var array<int, string>
2020-04-09 13:05:23 +02:00
*/
protected $fillable = [
2022-09-21 11:17:58 +00:00
'firstname',
'lastname',
'email',
'password',
2020-04-09 13:05:23 +02:00
];
/**
2023-09-22 09:59:11 +02:00
* The attributes that should be hidden for serialization.
2020-04-09 13:05:23 +02:00
*
2023-09-22 09:59:11 +02:00
* @var array<int, string>
2020-04-09 13:05:23 +02:00
*/
protected $hidden = [
2023-09-22 09:59:11 +02:00
'password',
'remember_token',
2020-04-09 13:05:23 +02:00
];
/**
2023-09-22 09:59:11 +02:00
* The attributes that should be cast.
2020-04-09 13:05:23 +02:00
*
2023-09-22 09:59:11 +02:00
* @var array<string, string>
2020-04-09 13:05:23 +02:00
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
2023-09-22 09:59:11 +02:00
/**
* Perform any actions required after the model boots.
*
* @return void
*/
protected static function booted()
{
// * EVENT CLOSURES.
static::creating(function (self $model) {
if (Hash::needsRehash($model->password)) {
$model->password = Hash::make($model->password);
}
});
static::updating(function (self $model) {
if (Hash::needsRehash($model->password)) {
$model->password = Hash::make($model->password);
}
});
}
2020-04-09 13:05:23 +02:00
}