Laravel Advanced Wheres how to pass variable into function?

前端 未结 4 2028
面向向阳花
面向向阳花 2020-11-29 18:38

Example in doc:

DB::table(\'users\')
        ->whereExists(function($query)
        {
            $query->select(DB::raw(1))
                  ->fro         


        
4条回答
  •  隐瞒了意图╮
    2020-11-29 18:56

    If you are using Laravel eloquent you may try this as well.

    $result = self::select('*')
                        ->with('user')
                        ->where('subscriptionPlan', function($query) use($activated){
                            $query->where('activated', '=', $roleId);
                        })
                        ->get();
    

提交回复
热议问题