0
I have a function that should return a json from a Collection generated by a Builder query.
$today = Carbon::today()->format('Y-m-d');
$tasks = Task::where('date', $today)->whereHas('collaborators', function($q) {
$q->where('collaborator_id', '=', Auth::user()->id)
->where('allocation', '=', 1)
->where('accepted', '=', 1)
->where('confirm_allocation', '=', 1);
})->with('event')->get();
However whenever I try to return the result with:
return response()->json($tasks, 200);
I get an error "Unexpected data found"
When doing a Dump and Die in the $tasks variable returns me the expected results.
That is, the return of json is gives rise to the error "Unexpected data found". If I remove the relation of the query, ie with('Event'), the results are already returned correctly and in json format, but I even need the relation to be returned too.