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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -