<?php

namespace Modules\SpecialAttendance\Entities;

use App\Models\User;
use App\Models\Traits\BranchTrait;
use App\Models\Traits\CompanyTrait;
use App\Models\coreApp\Status\Status;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Deduction extends Model
{
    use HasFactory, CompanyTrait, BranchTrait;

    protected $guarded = [];

    public function deductionDetails(): HasMany
    {
        return $this->hasMany(DeductionDetail::class);
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

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

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

    public function appealStatus(): BelongsTo
    {
        return $this->belongsTo(Status::class, 'appeal_status', 'id');
    }

    public function appealApprovedBy(): BelongsTo
    {
        return $this->belongsTo(User::class, 'appeal_approved_by', 'id');
    }
}
