Laravel 背包查询生成器 select 值或为空

Laravel Backpack Query Builder select value or is null

我正在为 laravel 使用背包 CRUD,我正在尝试请求我的数据库。我的问题是如何根据值或 null 连接表?

这就是我想要的

  select * from `baskets`
   inner join `users` on `baskets`.`donor_id` = `users`.`id`
   inner join `users` as `ass` on `baskets`.`association_id` = `ass`.`id` or `baskets`.`association_id` is null
   where `users`.`_lft` >= 1 and `users`.`_rgt` <= 1000
   group by `baskets`.`basket_id`
   order by `baskets`.`basket_id` desc, `end_removal_date` desc

这就是我尝试使用查询生成器所做的事情

   $this->crud->query->join('users', 'baskets.donor_id', '=', 'users.id');

    $this->crud->query->join('users as ass', function($join){
        $join->on('baskets.association_id', '=', 'ass.id');
        $join->orOn('baskets.association_id', 'is', \DB::raw('null');
    }

    $this->crud->addClause('where', 'users._lft', '>=', Auth::user()->_lft);
    $this->crud->addClause('where', 'users._rgt', '<=', Auth::user()->_rgt);

当然不行。 你有想法吗?

谢谢

使用这个:

$join->orWhereNull('baskets.association_id');