Update Laravel 5.3 from 5.2 and after I am getting an error
FatalErrorException in Builder.php line 638: Call to a member function all() on array
I used Laravel shift tool to upgrade framework and after successful composer update, I am facing this issue.
Code
public function index()
{
$static_block_array = [];
$static_block = StaticBlock::whereIn('identifier', [
'DESKTOP_STORE_FRONT_ROW_1_BLOCK',
'DESKTOP_STORE_FRONT_ROW_2_BLOCK',
'DESKTOP_BOTTOM_BLOCK','SOCIAL_MEDIA_ICON_BLOCK','TOP_ROW_HOMEPAGE_BLOCK'])
->remember(cacheTimeOut(CATALOG_CACHE_TIMEOUT))
->with("staticBlockContent")
->cacheTags(TAG_CATALOG)
->whereStatus(1)
->get();
foreach ($static_block as $value) {
$static_block_array[$value->identifier] = isset($value->staticBlockContent[0]) ? $value->staticBlockContent[0]->content : "";
}
return View::make('home/index')
->with('desktop_store_front_first_row', array_get($static_block_array, 'DESKTOP_STORE_FRONT_ROW_1_BLOCK', ''))
->with('desktop_store_front_second_row', array_get($static_block_array, 'DESKTOP_STORE_FRONT_ROW_2_BLOCK', ''))
->with('desktop_top_row_content', array_get($static_block_array, 'TOP_ROW_HOMEPAGE_BLOCK', ''))
->with('desktop_bottom_block', array_get($static_block_array, 'DESKTOP_BOTTOM_BLOCK', ''));
}
Issue is solved now. we created a custom logic to cache query in remember method we return a plain array but after converting to a collection object issue is solved.
return collect($cache->remember($key, $minutes, $callback));