<?php

namespace App\Models;

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

class PayrollEmployee extends Model
{
    use HasFactory;
    protected $with = ['employee'];

    public function employee()
    {
        return $this->belongsTo(User::class, 'employee_id');
    }

    protected $casts = [
        'allowances_array' => 'array',
        'deduction_array' => 'array',
        'bonus_array' => 'array',
        'non_statutory_deduction_array' => 'array',
    ];

    public function transaction()
    {
        return $this->hasOne(PayrollTransaction::class, 'payroll_employee_id');
    }
}
