84 lines
1.7 KiB
PHP
84 lines
1.7 KiB
PHP
<?php
|
|
namespace App\Models;
|
|
|
|
use App\Models\Notification;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use App\Models\Attendance;
|
|
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasFactory, Notifiable;
|
|
|
|
public function notifications(): HasMany
|
|
{
|
|
return $this->hasMany(Notification::class);
|
|
}
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'username',
|
|
'nik',
|
|
'email',
|
|
'password',
|
|
'role',
|
|
'skill',
|
|
'attendance_enabled',
|
|
'is_approved',
|
|
'email_verification_code',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
'attendance_enabled' => 'boolean',
|
|
'is_approved' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function attendances()
|
|
{
|
|
return $this->hasMany(Attendance::class);
|
|
}
|
|
|
|
/**
|
|
* Get the skill label
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getSkillLabelAttribute()
|
|
{
|
|
return match($this->skill) {
|
|
'mechanic' => 'Mekanik',
|
|
'welder' => 'Welder',
|
|
default => 'Belum diatur',
|
|
};
|
|
}
|
|
}
|
|
|