diff --git a/packages/actions/src/Action.php b/packages/actions/src/Action.php index 4787461c41..b3aa6d2848 100644 --- a/packages/actions/src/Action.php +++ b/packages/actions/src/Action.php @@ -512,7 +512,7 @@ class Action extends ViewComponent implements Arrayable */ protected function resolveDefaultClosureDependencyForEvaluationByType(string $parameterType): array { - $record = $this->getRecord() ?? $this->getSchemaContainer()?->getRecord() ?? $this->getSchemaComponent()?->getRecord(); + $record = $this->getRecord(); return match ($parameterType) { Builder::class => [$this->getSelectedRecordsQuery()], diff --git a/packages/actions/src/ActionGroup.php b/packages/actions/src/ActionGroup.php index 038afae9a9..4fa736f4e7 100644 --- a/packages/actions/src/ActionGroup.php +++ b/packages/actions/src/ActionGroup.php @@ -371,9 +371,9 @@ class ActionGroup extends ViewComponent implements Arrayable, HasEmbeddedView { return match ($parameterName) { 'livewire' => [$this->getLivewire()], - 'model' => [$this->getModel() ?? $this->getSchemaContainer()?->getModel() ?? $this->getSchemaComponent()?->getModel()], + 'model' => [$this->getModel()], 'mountedActions' => [$this->getLivewire()->getMountedActions()], - 'record' => [$this->getRecord() ?? $this->getSchemaContainer()?->getRecord() ?? $this->getSchemaComponent()?->getRecord()], + 'record' => [$this->getRecord()], 'schema' => [$this->getSchemaContainer()], 'schemaComponent', 'component' => [$this->getSchemaComponent()], 'schemaOperation', 'context', 'operation' => [$this->getSchemaContainer()?->getOperation() ?? $this->getSchemaComponent()?->getContainer()->getOperation()], diff --git a/packages/actions/src/Concerns/InteractsWithRecord.php b/packages/actions/src/Concerns/InteractsWithRecord.php index e0370262e6..a7841a0991 100644 --- a/packages/actions/src/Concerns/InteractsWithRecord.php +++ b/packages/actions/src/Concerns/InteractsWithRecord.php @@ -120,10 +120,6 @@ trait InteractsWithRecord return $record; } - if ($record = $this->getGroup()?->getRecord($withDefault)) { - return $record; - } - if (($this instanceof Action) && $record = $this->getSchemaContainer()?->getRecord()) { return $record; } @@ -132,11 +128,7 @@ trait InteractsWithRecord return $record; } - if ($withDefault && ($this instanceof Action) && ($record = $this->getHasActionsLivewire()?->getDefaultActionRecord($this))) { - return $record; - } - - return null; + return ($withDefault && ($this instanceof Action)) ? $this->getHasActionsLivewire()?->getDefaultActionRecord($this) : null; } public function getRecordTitle(?Model $record = null): ?string @@ -248,14 +240,14 @@ trait InteractsWithRecord $record = $this->getRecord($withDefault); - if (! is_null($record)) { - if (! ($record instanceof Model)) { - return ($withDefault && ($this instanceof Action)) ? $this->getHasActionsLivewire()?->getDefaultActionModel($this) : null; - } - + if ($record instanceof Model) { return $record::class; } + if ($record = $this->getGroup()?->getModel($withDefault)) { + return $record; + } + if ($this instanceof Action && $model = $this->getSchemaContainer()?->getModel()) { return $model; } @@ -264,7 +256,7 @@ trait InteractsWithRecord return $model; } - return null; + return ($withDefault && ($this instanceof Action)) ? $this->getHasActionsLivewire()?->getDefaultActionModel($this) : null; } /**