Skip to content

Commit

Permalink
[10.x] Move SetUniqueIds to run before the creating event (#46622)
Browse files Browse the repository at this point in the history
* Move SetUniqueIds to run before the creating event

This fixes a BC caused by PR #46161

* Update Model.php
  • Loading branch information
TFSThiagoBR98 authored Mar 29, 2023
1 parent 872c808 commit 6510073
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,10 @@ protected function getKeyForSaveQuery()
*/
protected function performInsert(Builder $query)
{
if ($this->usesUniqueIds()) {
$this->setUniqueIds();
}

if ($this->fireModelEvent('creating') === false) {
return false;
}
Expand All @@ -1287,10 +1291,6 @@ protected function performInsert(Builder $query)
$this->updateTimestamps();
}

if ($this->usesUniqueIds()) {
$this->setUniqueIds();
}

// If the model has an incrementing key, we can use the "insertGetId" method on
// the query builder, which will give us back the final inserted ID for this
// table from the database. Not all tables have to be incrementing though.
Expand Down

0 comments on commit 6510073

Please sign in to comment.