Skip to content

Commit 9a9f59f

Browse files
committed
refactor: extract attribute getter for insert.
1 parent 1c8038d commit 9a9f59f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,16 @@ protected function getKeyForSaveQuery()
989989
return $this->original[$this->getKeyName()] ?? $this->getKey();
990990
}
991991

992+
/**
993+
* Get all of the current attributes on the model for insert.
994+
*
995+
* @return array
996+
*/
997+
protected function getAttributesForInsert()
998+
{
999+
return $this->getAttributes();
1000+
}
1001+
9921002
/**
9931003
* Perform a model insert operation.
9941004
*
@@ -1011,7 +1021,7 @@ protected function performInsert(Builder $query)
10111021
// If the model has an incrementing key, we can use the "insertGetId" method on
10121022
// the query builder, which will give us back the final inserted ID for this
10131023
// table from the database. Not all tables have to be incrementing though.
1014-
$attributes = $this->getAttributes();
1024+
$attributes = $this->getAttributesForInsert();
10151025

10161026
if ($this->getIncrementing()) {
10171027
$this->insertAndSetId($query, $attributes);

0 commit comments

Comments
 (0)