<?php
/**
 * LaraOffice - Employee Deduction Model
 *
 * @category   Model
 * @package    HR
 * @subpackage Core
 * @author     LaraOffice
 * @license    MIT
 * @link       https://laraoffice.com
 */

namespace App\Modules\HR\Core\Models;

use App\Modules\HR\Payroll\Models\Deduction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class EmployeeDeduction extends Model
{
    use HasFactory;

    protected $table = 'employee_deductions';

    protected $fillable = [
        'employee_id',
        'deduction_id',
        'calculation_type',
        'amount',
        'status',
    ];

    protected $casts = [
        'status' => 'boolean',
        'amount' => 'decimal:2',
    ];

    public function employee(): BelongsTo
    {
        return $this->belongsTo(Employee::class);
    }

    public function deduction(): BelongsTo
    {
        return $this->belongsTo(Deduction::class);
    }
}
