jeudi 19 août 2021

How to pass condition in laravel 5 relation model

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



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3CTZA65
via IFTTT

Aucun commentaire:

Enregistrer un commentaire