<?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\Traits\HasEmployee;
use Modules\HR\Models\Traits\SalaryStructureRelationshipTrait;

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


class SalaryStructure extends Model
{
    use SalaryStructureRelationshipTrait ,HasEmployee, HasStatus, HasFactory;

    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = [
        'employee_id',
        'name',
        'effective_from',
        'effective_to',
        'is_locked',
        'status',
    ];

    public function scopeSearch($query, $search)
    {
        $search = '%' . trim($search) . '%';

        return $query->where(function ($q) use ($search) {
            $q->where('name', 'LIKE', $search);
        });
    }

    protected $casts = [
        'is_locked' => 'boolean',
    ];


}
