我想用laravel背包做一个过滤器。 这是我的代码:
$this->crud->addFilter([
'type' => 'simple',
'name' => 'haspostessurplus',
'label' => 'Postes en surplus',
],
false,
function () {
$this->crud->addClause('whereHas', 'postes' , function($query) {
$query->where('postes', '>', 'nb_postes');
});
});
我的帖子关系:
public function postes()
{
return $this->hasMany('App\Models\Postes');
}
我想向我的societies
展示与他们的字段postes
相比,他们在nb_postes
方面的联系更多。
但是我不知道如何计算这种关系?
laravel查询生成器经典版没有问题,但是我不知道这种语法:(