Laravel BackPack计数关系过滤器

时间:2020-08-19 06:53:31

标签: laravel backpack-for-laravel laravel-backpack

我想用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查询生成器经典版没有问题,但是我不知道这种语法:(

0 个答案:

没有答案