【发布时间】:2020-05-18 12:40:47
【问题描述】:
我的页面应该显示来自不同表格的总和。当我尝试用代码求和时:
$games = Game::where('winner_id', $user->id)->get();
$games_low = GameLow::where('winner_id', $user->id)->get();
$wins = $games + $games_low->count();
$wins = $wins;
$totalBank = $games->sum('price');
我收到错误Object of class Illuminate\Database\Eloquent\Collection could not be converted to int。我该如何解决这个问题?
【问题讨论】:
-
什么是
$gamesPlayed? -
这是从数据库中显示的游戏计数,我不在刀片上使用
$winrate和$gamesPlayed变量,我编辑我的问题。
标签: laravel