簡體   English   中英

從 Laravel 5.2 更新到 5.3 后調用數組上的成員函數 all()

[英]Call to a member function all() on array After update from Laravel 5.2 to 5.3

從 5.2 更新 Laravel 5.3 並在我收到錯誤后

https://i.stack.imgur.com/yEdH3.png

Builder.php 第 638 行中的 FatalErrorException:調用數組上的成員函數 all()

我使用 Laravel shift 工具升級框架,在成功更新 composer 后,我面臨這個問題。

代碼

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', ''));
}

問題現已解決。 我們創建了一個自定義邏輯來在記住方法中緩存查詢,我們返回一個普通數組,但在轉換為集合對象后問題解決了。

 return collect($cache->remember($key, $minutes, $callback));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM