67 lines
1.4 KiB
PHP
67 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 Illuminate\Contracts\Auth\CanResetPassword;
|
|
|
|
|
|
class User extends Authenticatable implements MustVerifyEmail
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'email_verified_at',
|
|
'phone',
|
|
'alamat',
|
|
'password',
|
|
'photo',
|
|
'level',
|
|
'remember_token',
|
|
];
|
|
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var array
|
|
*/
|
|
public static $rules = [
|
|
'name' => 'required|string',
|
|
'email' => 'required|email|unique:users',
|
|
'password' => 'required|string',
|
|
'level' => 'in:user,admin',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected $casts = [
|
|
'email_verified_at' => 'datetime',
|
|
];
|
|
|
|
public function setPasswordAttribute($password)
|
|
{
|
|
$this->attributes['password'] = $password;
|
|
}
|
|
|
|
}
|