Laravel 5.1 eloquent Unsupported operand types -


i trying query result array , show them in select element. when hardcode this, works fine:

$categories = ['editorial', 'product test', 'news', 'feature']; $categories = ['select_category']+$categories;    return view('admin.articles.create', compact('categories')); 

but when try categories form db, above mentioned error.

$categories = category::all(); $categories = ['select_category']+$categories;  return view('admin.articles.create', compact('categories')); 

category::all(); return collection , not array.

you should able around using toarray() e.g.

$categories = category::all()->toarray(); 

hope helps!


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -