Я пытаюсь использовать updateOrCreate, чтобы упростить мой код, но функция ВСЕГДА создает новую строку, никогда не обновляет.
Моя миграция:
Schema::create('logs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('project_id')->unsigned();
$table->datetime('is_fixed')->nullable();
$table->datetime('snooze_until')->nullable();
$table->integer('snooze_while')->nullable();
$table->string('title', 100);
$table->string('level', 100);
$table->string('description');
$table->string('stage',100);
$table->json('details')->nullable();
$table->timestamps();
$table->foreign('project_id')->references('id')->on('projects');
});
Мои $ fillables
protected $fillable = [
'project_id',
'is_fixed',
'snooze_until',
'snooze_while',
'title',
'level',
'description',
'stage',
'details'
];
Мой тест
$log = new Log();
$log->fill([
'title' => 'Vicente\\Sally\\Schiller',
'level' => 'ERROR',
'description' => 'Laboriosam et architecto voluptatem.',
'stage' => 'production@wender-fedora',
'details' => '{"app":"MyApp"}',
'project_id' => 5
]);
Log::updateOrCreate($log->toArray());
У меня есть некоторые пустые поля, но я думаю, это не проблема.