<?php

namespace Modules\HR\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Core\Traits\HasStatus;
use Modules\Employee\Models\Religion;

// use Modules\HR\Database\Factories\FestivalBonusPolicyFactory;

class FestivalBonusPolicy extends Model
{
    use HasStatus, HasFactory;

    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = [
        'festival_name',
        'eligibility',
        'religion_id',
        'bonus_type',
        'bonus_value',
        'minimum_service_days',
        'status',
    ];

    public function scopeSearch($query,  $term)
    {
        if (blank($term)) {
            return $query;
        }
        $term = '%' . trim($term) . '%';
        return $query->where('festival_name', 'like', $term)
            ->orWhere('bonus_type', 'like', $term);
    }

    public function religion()
    {
        return $this->belongsTo(Religion::class);
    }

}
