<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class PayrollStructure extends Model
{
    public function employee(){
        return $this->belongsTo('App\Models\Employee','employee_id','id');
    }
    public function designationName()
    {
        return $this->belongsTo('App\Models\EmploymentDetail','employee_id','employee_id')->orderBy('id','ASC');
    }
    public function grade(){
        return $this->belongsTo('App\Models\Grade','grade_id','id');
    }
    public function gradeHead(){
        return $this->hasMany('App\Models\GradeStructure','grade_id','grade_id');
    }
    public function psHead(){
        return $this->hasMany('App\Models\PayrollStructureDetail','structure_id','id');
    }
    public function due(){
        return $this->hasMany('App\Models\PayrollHistory','employee_id','employee_id');
    }
    public function payableDue(){
        return $this->hasMany('App\Models\PayrollHistory','employee_id','employee_id')->orderBy('created_at','DESC');
    }
}
