首页 > 解决方案 > 主页不会显示新添加的记录,但其他页面会显示

问题描述

去年 2019 年,我在一个旧的 Web 项目中使用 Laravel 5.7,但现在我遇到了一个非常奇怪的错误。这是一个网站,当您添加新游戏时,它将显示在菜单列表中,如果有特色,它将显示在主页内容中。

这是桌子['game_id', 'name', 'key', 'status', 'order', 'is_featured']

在标题视图中,我输入了以下代码:

<ul class="nav-menu">
          <li class="{{ ($page == "games" ? 'menu-active' : '') }} submenu dropdown"><a href="/games" >Games</a>
            <ul class="dropdown-menu">
               @foreach(GetPublishedGames() as $game)
                <li class="nav-item"><a href="/games/{{$game->key}}">{{$game->name}}</a></li>
               @endforeach
            </ul>
          </li>
...

调用这个帮助代码GetPublishedGames()

function GetPublishedGames(){
        $data = DB::table("game")->where("status", 1)->orderBy("order")->get();
        return $data;
    }

在主页控制器中我有这条线 "feat_games" => Game::where("status", 1)->where("is_featured", 1)->orderBy("order")->limit(5)->get(),

在主页视图中调用:

@if(count($feat_games))
              @foreach($feat_games as $feat_game)
                <div class="feat-game-item wow fadeInUp">
                  ... some content ...
                </div>
              @endforeach
            @endif

我不知道为什么会发生这种情况,它之前在本地和开发阶段有效。我确实试图清除缓存。

任何想法?

标签: laravellaravel-5.7

解决方案


推荐阅读