我在模型FeeModuleModel中具有关系,如下所示
public function heads()
{
return $this->hasMany('App\Models\FeeHeadModel','location_id','id');
}
并且在我的控制器文件中,我只需要获取FeeHeadModel类型为非结构化类型的值FeeModuleModel我的控制器代码如下所示
$modules = FeeModuleModel::where('vt_ay_id', '=', Session::get('sess_ay_id'))->with(['heads'=>function($q){
$q->where('type','=','unstructured');
}])->orderby('priority', 'asc')->get();
此操作失败,并出现以下错误
在数组上调用成员函数getRelationExistenceQuery()
我的代码有什么问题,我该怎么解决
请将此代码更改为此代码
$modules = FeeModuleModel::with(['heads'=>function($q){
$q->where('type','=','unstructured');
}])->where('vt_ay_id', '=', Session::get('sess_ay_id'))->orderby('priority', 'asc')->get();