I'm trying to query data from btween two date from my date column. I tested using api
http://127.0.0.1:8000/api/expense?start=2019-08-01&2019-08-04
but its give me all the records not from date range?
My Controller
public function index(Request $request)
{
$user = auth()->user();
$expenses = Expense::whereHas('user', function($subQuery) use($user){
return $subQuery->where('shop_id', '=', $user->shop_id);
})->with(['user'])->get();
if($request->start && $request->end) {
$expenses->where(function($q) use ($request) {
$q->whereBetween('date', array($request->start, $request->end));
});
}
return ExpenseResource::collection($expenses);
}
i think i do something wrong with my Controller, but i cant still figure it out..
Thanks in advances...
"explode() expects parameter 2 to be string, object given"