Skip to content

Commit ff994bc

Browse files
author
Pantea Marius-ciclistu
committed
Cache getCasts in model cr
1 parent 48c7128 commit ff994bc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Models/BaseModel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ abstract class BaseModel extends Model
5858
*/
5959
public function __construct(array $attributes = [])
6060
{
61+
if ($this->incrementing) {
62+
$this->casts[$this->getKeyName()] ??= $this->getKeyType();
63+
}
64+
6165
parent::__construct($attributes);
6266

6367
$this->initializeActiveRecordSegregationProperties();
6468

6569
$this->appends[] = 'primary_key_identifier';
66-
67-
if ($this->incrementing) {
68-
$this->casts[$this->getKeyName()] ??= $this->getKeyType();
69-
}
7070
}
7171

7272
public static function resourceName(): string

0 commit comments

Comments
 (0)