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 ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2xJEsiL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire