我正在尝试insertOrIgnore从 Laravel DB Facade实现方法,这是文档 + 解释片段的链接:https ://laravel.com/docs/5.8/queries#inserts
insertOrIgnore 方法将在向数据库中插入记录时忽略重复记录错误:
DB::table('users')->insertOrIgnore([
['id' => 1, 'email' => 'taylor@example.com'],
['id' => 2, 'email' => 'dayle@example.com']
]);
这是产生错误的代码段(它适用于常规insert())
if ($datetime->format('H:i') >= '05:50' && $datetime->format('H:i') <= '07:10') {
DB::table('attendanceTable')->insertOrIgnore(['user_id' => $request->loggedUserId, 'day' => $datetime, 'shift_id' => $Shifts->id, 'created_at' => $datetime, 'updated_at' => $datetime]);
这是 Laravel 望远镜产生的错误
Call to undefined method Illuminate\Database\Query\Builder::insertOrIgnore()
有人可以指出我做错了什么,或者至少给我一个提示?提前致谢!
HUH函数