laravel - 主页不会显示新添加的记录,但其他页面会显示
问题描述
去年 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
我不知道为什么会发生这种情况,它之前在本地和开发阶段有效。我确实试图清除缓存。
任何想法?
解决方案
推荐阅读
- python - limit_choices_to 与 A 或 B 逻辑
- javascript - VueJs 从数据库中选择默认值
- gcc - 为什么__pool_alloc_base的实现在gcc/libstdc++-v3/src/c++98/pool_allocator.cc?
- jquery - 电子表格不呈现数据
- java - Firebase如何在Android中打开其他活动时删除ValueEventListeners
- c# - 如何使用 C# 在 bot 框架 SDKV4 中开发的网络聊天中显示每条消息的聊天日期和时间?
- python - 检索相对于数据框中特定行具有今天日期的列名
- swift - 我们为什么要使用扩展?
- magento - Magento 如何在集合中使用封闭的 AND & OR 条件
- linkedin - 如何访问 Skill Api(标准化数据)?