Why response failed to load when use get() in query in Lumen

102 views Asked by At

I tried to get data from db having the particular id . The code is as follows :

$obj = new Products();
       $res= $obj->select('*')->where('track_id',$trackId)->orderBy('shipping_date', 'desc')->get();

But I am getting error as 'Failed to load Response Data'.

I have no idea why this error occurs. Someone please help me.

1

There are 1 answers

3
Dark Knight On

If you're using eloquent model, you can directly use class name to fetch records in following manner.

$obj = App\Product::where('track_id',$trackId)
         ->orderBy('shipping_date', 'desc')
         ->get();

Reference: Retrieving Model