I am trying to get the data from group model but i am relate the student table new_group_id
to group table id if it not null else connect the group_id
to group table id.
public function grade(Builder $query)
{
return $query
->when($this->new_group_id != 0, function ($q) {
return $q->with('new_group_id');
})
->when($this->new_group_id === 0, function ($q) {
return $q->with('group_id');
});
}
But given the error is
Argument 1 passed to App\Students::grade() must be an instance of App\Builder
please help me to solve these error