<?php

namespace Modules\Employee\Models;

use Illuminate\Database\Eloquent\Model;
use Modules\Core\Traits\HasStatus;
use Modules\Employee\Models\Traits\DesignationRelationshipTrait;
use Modules\Employee\Models\Traits\HasEmployees;
use Modules\Employee\Models\Traits\HasGrade;
use Modules\Employee\Models\Traits\HasStaff;

class Designation extends Model
{
    use HasStatus,
        HasStaff,
        HasGrade,
        HasEmployees;

    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = [
        'name',
        'staff_type_id',
        'salary_grade_id',
        'status'
    ];

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

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

    public $timestamps = false;
}
