I learning Laravel
and have a recursive table that I need to loop through to get the null
values as I need to then get the id's that they are linked to in order show the articles.
How can I loop through this in my blade template?
Blade view is returning... htmlspecialchars(): Argument #1 ($string) must be of type string, array given
Blade Template
@foreach ($categories as $category)
{{$category}}
@endforeach
Controller
$categories = array();
$parentCategories = Category::where('parent_id', null)->get();
foreach($parentCategories as $parentCategory){
$categories[] = Category::where('parent_id',$parentCategory->id)->with('articles')->get();
};
return view('marketplace.categories.index', [
'categories' => $categories
]);
Database Table