Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/EloquentBacking.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function get(): Model
public function fresh(): Model
{
$model = static::model()->newQuery()
->where($this->attributes())
->where($this->eloquentIdentityAttributes())
->firstOr(fn() => $this->createMissing());

// This ensures that if this specific model is updated or deleted,
Expand Down Expand Up @@ -171,7 +171,7 @@ protected function createMissing(): Model
return static::model()->newQuery()->create($this->attributesForCreation());
}

protected function attributes(): array
protected function eloquentIdentityAttributes(): array
{
return [
static::getKeyColumn() => static::valueToAttribute($this->value),
Expand All @@ -181,13 +181,13 @@ protected function attributes(): array
protected function attributesForCreation(): array
{
return array_merge(
$this->attributes(),
$this->values(),
$this->eloquentIdentityAttributes(),
$this->eloquentAdditionalAttributes(),
$this->createWith(),
);
}

protected function values(): array
protected function eloquentAdditionalAttributes(): array
{
return Arr::except(ValueHelper::getValuesFor($this), [static::getKeyColumn()]);
}
Expand Down