50 lines
1.0 KiB
PHP
50 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Employee extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'user_id', // diisi oleh UserController saat akun digenerate
|
|
'nip',
|
|
'name',
|
|
'email',
|
|
'gender',
|
|
'place_of_birth',
|
|
'birth_date',
|
|
'address',
|
|
'phone_number',
|
|
'department_id',
|
|
'position_id',
|
|
'status',
|
|
'join_date',
|
|
];
|
|
|
|
// Relasi ke User (nullable: karyawan boleh belum punya akun)
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class)->withDefault();
|
|
}
|
|
|
|
// Relasi ke Departemen
|
|
public function department()
|
|
{
|
|
return $this->belongsTo(Department::class);
|
|
}
|
|
|
|
// Relasi ke Jabatan
|
|
public function position()
|
|
{
|
|
return $this->belongsTo(Position::class);
|
|
}
|
|
|
|
public function attendances()
|
|
{
|
|
return $this->hasMany(Attendance::class);
|
|
}
|
|
} |