2

I've following query:

$visible = array(1,2,3);
$views = DB::table('ims_view')
    ->Where(function($query) {
        $query->where('iv_status', 1)->whereIn('id', $visible);
    })->orderBy('iv_name', 'asc')->get();

Error: Undefined variable: visible

How to pass the variabnle to inner where?

1 Answer 1

4

you have to use the variable you want passed into the scope like so: use ($visible)

`$views = DB::table('ims_view')
    ->Where(function($query) use ($visible){
           $query->where('iv_status', 1)
                  ->whereIn('id', $visible);
            })->orderBy('iv_name', 'asc')->get();`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.