mardi 1 mars 2016

query database using variable in eloquent

I am trying to query for records using eloquent.

this works fine:

    $xs = X::all()->where('y_id', 1);
    return view('x', compact('xs'));

but when i try to pass a variable:

    $xs = X::all()->where('y_id', $id);
    return view('x', compact('xs'));

it returns empty array!

how can I do this query?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1oOevr0
via IFTTT

Aucun commentaire:

Enregistrer un commentaire