26 lines
508 B
PHP
26 lines
508 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Models;
|
||
|
|
||
|
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
||
|
class Grade extends Model
|
||
|
{
|
||
|
use HasFactory;
|
||
|
|
||
|
protected $fillable = [
|
||
|
'name',
|
||
|
];
|
||
|
|
||
|
public function scopeFilter(Builder $query)
|
||
|
{
|
||
|
$name = request('name');
|
||
|
|
||
|
$query->when($name, function (Builder $query, $name) {
|
||
|
$query->whereRaw('name ilike ?', ["$name%"]);
|
||
|
});
|
||
|
}
|
||
|
}
|