Laravel Query Builder Advance Where

laravel, laravel-4

Solution

If you want to use variables in your closure, you must include them.

Change

->where(function($query) {

to

->where(function($query) use ($status) {

Problem

Laravel Advance Query Builder not seeing parent method variable ``` public function read($status=null,$skip=0,$take=10,$orderby=array()) { $table = DB::table('users') ->skip($skip) ->take($take) ->where(function($query) { if($status) $query->where('status','!=',$status); }); } ``` This returns an error which $status variable undefined inside the advance where query. Is there anything to extend?

Original source