<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class PayrollPayment extends Model
{
    protected $fillable = [
        'user_id',
        'month',
        'year',
        'base_salary',
        'total_addition',
        'total_deduction',
        'total_payable',
        'created_by',
        'is_deleted',
        'created_at',
        'updated_at',
        'deleted_at',
    ];

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

    public function creator(): BelongsTo
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function additions(): HasMany
    {
        return $this->hasMany(PaymentAddition::class, 'payment_id');
    }

    public function deductions(): HasMany
    {
        return $this->hasMany(PaymentDeduction::class, 'payment_id');
    }
}
