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
Post a Comment