arctushar
1 year ago

WhereHas showing error why?

Posted 1 year ago by arctushar

I have Three Model- Sector, Codelist and Dsedata. Basis of this I have eloquent as below which works

$datas=Sector::with(['codelists.dsedata'=>function($query)use($date1){
    $query->select('id','codelist_id','date','volume')->where('dsedatas.date',$date1)->where('volume','>',600);
}])->get();

But when I add whereHas as below command. it show error

$datas=Sector::whereHas(['codelists.dsedata'=>function($query)use($date1){
    $query->select('id','codelist_id','date','volume')->where('dsedatas.date',$date1)->where('volume','>',600)->get();
}])->with(['codelists.dsedata'=>function($query)use($date1){
    $query->select('id','codelist_id','date','volume')->where('dsedatas.date',$date1)->where('volume','>',600);
}])->get();

The error is : Method name must be a string

and the error location is

    protected function getRelationWithoutConstraints($relation)
    {
        return Relation::noConstraints(function () use ($relation) {
            return $this->getModel()->{$relation}();
        });
    }
 

Please sign in or create an account to participate in this conversation.