Getting error message from Laravel's foreach loop:
Invalid argument supplied for foreach()
My foreach loop is :
@foreach ($task as $tasks)
<td>{{$tasks->name}}</td>
@endforeach
My controller is:
public function show($id){
$task = Task::find($id);
return view('tasks.show')->withTask($task);
;
}
$tasktraversable?dd($task)before the foreach inside blade.$task = Task::find($id);. It just returns the matchingTaskobject