laravel - Will Model::updateOrCreate() update a soft-deleted model if the criteria matches? -
let's have model soft-deleted , have following scenario:
// existing soft-deleted model's properties $model = [ 'id' => 50, 'app_id' => 132435, 'name' => 'joe original', 'deleted_at' => '2015-01-01 00:00:00' ]; // new properties $properties = [ 'app_id' => 132435, 'name' => 'joe updated', ]; model::updateorcreate( ['app_id' => $properties['app_id']], $properties );
is joe original
joe updated
?
or there deleted record , new joe updated
record?
updateorcreate model deleted_at equal null won't find soft-deleted model. however, because won't find try create new 1 resulting in duplicates, not need.
btw, have error in code. model::updateorcreate takes array first argument.
Comments
Post a Comment