I am trying to get query result to array and show them in select element. When I hardcode it like this, it works fine:
$categories = ['Editorial', 'Product test', 'News', 'Feature'];
$categories = ['select_category']+$categories;
return view('admin.articles.create', compact('categories'));
But when I try to get categories form DB, I get the above mentioned error.
$categories = Category::all();
$categories = ['select_category']+$categories;
return view('admin.articles.create', compact('categories'));
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire