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?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire