Archived
1
0
Fork 0
This repository has been archived on 2026-06-16. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
heritage-wow/app/Models/User.php

67 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable, SoftDeletes;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'discord_id',
'username',
'password',
'role'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
protected static function boot()
{
parent::boot();
static::deleted(function ($user) {
$user->characters()->delete();
});
}
public function characters()
{
return $this->hasMany(Character::class);
}
public function getRoleAttribute()
{
if (!$this->attributes['role']) {
return 'user';
}
return $this->attributes['role'];
}
}