<?php

namespace App\Models;

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

class AttendancePostingDtls extends Model
{
    use HasFactory;

    protected $table = "attendance_posting_details";

    protected $guarded = [];

    public function header() {

        return $this->belongsTo(AttendancePosting::class, 'header_id');
    }

    public function employee() {
        return $this->belongsTo(Employee::class, 'employee_id', 'employee_id')->select('employee_id','firstname', 'middlename', 'lastname', 'position_id');
    }

    public function department() {
        return $this->hasOne(Department::class, 'id', 'department_id')->select('id','name');
    }

    public function job_title(): BelongsTo 
    {
        return $this->belongsTo(JobTitle::class, 'position_id');
    }
}
