Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/product-variant-attribute-fi…
Browse files Browse the repository at this point in the history
…lling' into prod
  • Loading branch information
Aidas Klimas committed Oct 22, 2024
2 parents 609a560 + 311a5fe commit b9a8ccb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 14 additions & 1 deletion packages/admin/src/Filament/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static function getWidgets(): array
public static function getDefaultForm(Form $form): Form
{
return $form
->schema([
->schema(fn (Product $record) => [
Shout::make('product-status')
->content(
__('lunarpanel::product.status.unpublished.content')
Expand All @@ -123,6 +123,19 @@ public static function getDefaultForm(Form $form): Form
static::getMainFormComponents(),
),
static::getAttributeDataFormComponent(),
...(
$record->variants->count() === 1 ?
[Forms\Components\Repeater::make('variants')
->relationship()
->schema([
Attributes::make()->statePath('attribute_data')
])
->maxItems(1)
->addable(false)
->deletable(false)
->label('Variant details')] :
[]
)
])
->columns(1);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/admin/src/Support/Forms/Components/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ protected function setUp(): void

if (blank($this->childComponents)) {
$this->schema(function (\Filament\Forms\Get $get, Livewire $livewire, ?Model $record) {
$modelClass = $livewire::getResource()::getModel();

$productTypeId = null;

$morphMap = $modelClass::morphName();
$morphMap = $record ? $record::morphName() : $livewire::getResource()::getModel()::morphName();

$attributeQuery = Attribute::where('attribute_type', $morphMap);

Expand Down

0 comments on commit b9a8ccb

Please sign in to comment.