<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Staff extends Model
{
    use HasFactory;

    protected $primaryKey = 'emp_id';

    protected $fillable = [
        'first_name',
        'last_name',
        'email',
        'contact_no',
        'id_card_type',
        'id_card_no',
        'address',
        'staff_type_id',
        'shift_id',
    ];

    /**
     * Get the id card type for this staff.
     */
    public function idCardType()
    {
        return $this->belongsTo(IdCardType::class, 'id_card_type');
    }

    /**
     * Get the staff type for this staff.
     */
    public function staffType()
    {
        return $this->belongsTo(StaffType::class, 'staff_type_id');
    }

    /**
     * Get the shift for this staff.
     */
    public function shift()
    {
        return $this->belongsTo(Shift::class, 'shift_id');
    }

    /**
     * Get the employee histories for this staff.
     */
    public function empHistories()
    {
        return $this->hasMany(EmpHistory::class, 'emp_id');
    }
}
