sidakpelem/app/Models/User.php

67 lines
1.4 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens; // ✅ TAMBAHKAN INI
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable; // ✅ TAMBAHKAN HasApiTokens
protected $fillable = [
'name',
'nik',
'email',
'password',
'device_id',
'role',
'jabatan',
'phone',
'no_telepon',
'employee_id',
'status',
'jenis_kelamin',
'tempat_lahir',
'tanggal_lahir',
'address',
'alamat',
'url_photo',
'hire_date',
'otp',
'otp_expires_at',
];
protected $hidden = [
'password',
'remember_token',
];
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'hire_date' => 'date',
'tanggal_lahir' => 'date',
'otp_expires_at' => 'datetime',
];
}
public function attendances()
{
return $this->hasMany(Attendance::class);
}
public function pengajuans()
{
return $this->hasMany(Pengajuan::class, 'id_user');
}
public function todayAttendance()
{
return $this->attendances()->whereDate('date', today())->first();
}
}