Skip to content

Commit

Permalink
refactor: extract attribute getter for insert.
Browse files Browse the repository at this point in the history
  • Loading branch information
donnysim committed Apr 13, 2021
1 parent 1c8038d commit 9a9f59f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,16 @@ protected function getKeyForSaveQuery()
return $this->original[$this->getKeyName()] ?? $this->getKey();
}

/**
* Get all of the current attributes on the model for insert.
*
* @return array
*/
protected function getAttributesForInsert()
{
return $this->getAttributes();
}

/**
* Perform a model insert operation.
*
Expand All @@ -1011,7 +1021,7 @@ protected function performInsert(Builder $query)
// 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.
$attributes = $this->getAttributes();
$attributes = $this->getAttributesForInsert();

if ($this->getIncrementing()) {
$this->insertAndSetId($query, $attributes);
Expand Down

0 comments on commit 9a9f59f

Please sign in to comment.