Php laravel 5.4查询异常未知列错误
我有这条裤子Php laravel 5.4查询异常未知列错误,php,laravel-5.4,Php,Laravel 5.4,我有这条裤子 Route::get('/artist/{id}/{slug}', 'HomeController@artist')->name('artist'); 这就是现代艺术家 public function artist($id,$slug){ $artist = Artist::where('id', $id)->where('slug', $slug)->first(); $hits = Artist::where('id', $i
Route::get('/artist/{id}/{slug}', 'HomeController@artist')->name('artist');
这就是现代艺术家
public function artist($id,$slug){
$artist = Artist::where('id', $id)->where('slug', $slug)->first();
$hits = Artist::where('id', $id)->where('slug', $slug)->increment('week_hits');
return view('front.artist', compact('artist'));
}
我想要的是在我的艺术家表中增加周点击量。每当用户访问特定的艺术家页面时
但是我犯了这个错误
QueryException in Connection.php line 647:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'week_hits' in 'field list' (SQL: update `artists` set `week_hits` = `week_hits` + 1, `updated_at` = 2017-02-26 16:20:04 where `id` = 1 and `slug` = xasan-aadan-samatar)
你能提供你的表结构吗?为什么你要显示PHP代码,而错误清楚地表明:SQL。
Artist
model(可能是artists)的表中是否有列名week\u hits?是的。这是我的桌子结构。id、姓名、slug、图像、传记、周点击率、周日期、状态、创建时间、更新_at@LukaGovedi谢谢兄弟。我刚刚检查了我的桌子结构。再一次。没有字段名为week_hits,它是week_htis。我知道了,谢谢兄弟。是的,打字错误是最常见也是最烦人的错误