belongsToMany(Grade::class); } public function teachers(): BelongsToMany { return $this->belongsToMany(Teacher::class); } public function scopeFilter(Builder $query): void { $name = request('name'); $query->when($name, function (Builder $query, $name) { $query->whereRaw('name ilike ?', ["$name%"]); }); } public function user(): MorphOne { return $this->morphOne(User::class, 'userable'); } }