Skip to content

Commit

Permalink
Allow variants to be disabled in panel (#1456)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecritson authored Jan 8, 2024
1 parent 0b27fa6 commit 6a0d915
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/admin/config/panel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Enable Variants
|--------------------------------------------------------------------------
|
| When `true` this will show the Variants manager when editing a product. If your
| storefront doesn't support variants, set this to false.
|
*/
'enable_variants' => true,
];
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Filament\Support\Facades\FilamentIcon;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
use Lunar\Admin\Filament\Resources\ProductResource;

class ManageProductVariants extends ManageRelatedRecords
Expand All @@ -23,6 +24,20 @@ public static function getNavigationIcon(): ?string
return FilamentIcon::resolve('lunar::product-variants');
}

public static function shouldRegisterNavigation(array $parameters = []): bool
{
return config('lunar.panel.enable_variants', true);
}

public static function canAccess(Model $record = null): bool
{
if (! config('lunar.panel.enable_variants', true)) {
return false;
}

return parent::canAccess($record);
}

public static function getNavigationLabel(): string
{
return 'Variants';
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src/LunarPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class LunarPanelProvider extends ServiceProvider
{
protected $configFiles = [
'search',
'panel',
];

protected $root = __DIR__.'/..';
Expand Down

0 comments on commit 6a0d915

Please sign in to comment.