vendredi 28 septembre 2018

How change static select on object select?

I can select data from table using for example code below

$ab = Order::where('user_id', 2);
    ->where('stock_id', 30);
    ->get();     
dd($ab);

And is ok, but i need create search condition and i would like create query like this below

$ab = new Order();
!empty($request->user_id) ? $ab->where('user_id', $request->user_id) : false;
!empty($request->stock_id) ? $ab->where('stock_id', $request->stock_id) : false;
dd($ab->get());

And not working. Could anyone give me a hint ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire