<?php

namespace App\Models;

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

class BonusGeneration extends BaseModel
{
    protected $fillable = [
        'bonus_id',
        'month',
        'status',
        'generated_by',
        'approved_by',
        'approved_at',
    ];

    protected function casts(): array
    {
        return [
            'month' => 'date',
            'approved_at' => 'datetime',
        ];
    }

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

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

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

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