CourseWork/app/Models/Grade.php

26 lines
508 B
PHP
Raw Normal View History

2024-04-16 13:27:51 +04:00
<?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%"]);
});
}
}