Skip to content

Commit

Permalink
feat: Model column by key
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Mar 9, 2025
1 parent 19db162 commit 9c72459
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Laravel/src/Resources/ModelResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ abstract class ModelResource extends CrudResource implements

protected string $model;

protected string $column = '';

public function flushState(): void
{
parent::flushState();
Expand All @@ -53,6 +55,11 @@ public function flushState(): void
$this->customQueryBuilder = null;
}

public function getColumn(): string
{
return $this->column ?: $this->getModel()->getQualifiedKeyName();
}

/**
* @return TData
*/
Expand Down Expand Up @@ -250,7 +257,7 @@ protected function afterSave(mixed $item, FieldsContract $fields): mixed
protected function search(): array
{
return [
$this->getModel()->getKeyName(),
$this->getModel()->getQualifiedKeyName(),
];
}
}
2 changes: 2 additions & 0 deletions src/UI/src/Components/MoonShineComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function __construct(
}

$this->booted();

$this->class('moonshine-component');
}

protected function booted(): void
Expand Down

0 comments on commit 9c72459

Please sign in to comment.