小编Zez*_*zen的帖子

laravel内的未定义变量左连接

在我的情况下,我想显示每个用户完成的用户和订单,订单有状态我从输入表单获得$ status这里是我的代码

$orders = DB::table('user_profiles')
        ->leftJoin('orders', function($join){
            $join->on('user_profiles.id','=','orders.id_user')
                ->where('orders.status','=',$status);
        })
        ->selectRaw('user_profiles.*, count(orders.id_user) as order_try_count')
        ->groupBy('user_profiles.id')
        ->orderBy('order_try_count',$order)
        ->paginate(15);
Run Code Online (Sandbox Code Playgroud)

但我得到未定义的变量状态,我该怎么做才能解决这个问题?,谢谢

php anonymous-function laravel eloquent laravel-5

3
推荐指数
1
解决办法
1281
查看次数

标签 统计

anonymous-function ×1

eloquent ×1

laravel ×1

laravel-5 ×1

php ×1