Skip to content

Commit 68c4202

Browse files
committed
feat: add settings
1 parent c46e9ba commit 68c4202

5 files changed

Lines changed: 83 additions & 1 deletion

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Spatie\LaravelSettings\Migrations\SettingsMigration;
4+
5+
return new class extends SettingsMigration
6+
{
7+
public function up(): void
8+
{
9+
$this->migrator->add('frontend.guest_access', true);
10+
}
11+
};
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace Eclipse\Frontend\Admin\Filament\Pages;
4+
5+
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
6+
use Eclipse\Common\CommonPlugin;
7+
use Eclipse\Frontend\Settings\FrontendSettings;
8+
use Filament\Forms\Components;
9+
use Filament\Forms\Form;
10+
use Filament\Pages\SettingsPage;
11+
use Illuminate\Contracts\Support\Htmlable;
12+
13+
class ManageFrontend extends SettingsPage
14+
{
15+
use HasPageShield;
16+
17+
protected static ?string $navigationIcon = 'heroicon-o-building-storefront';
18+
19+
protected static string $settings = FrontendSettings::class;
20+
21+
public function form(Form $form): Form
22+
{
23+
return $form
24+
->schema([
25+
Components\Toggle::make('guest_access')
26+
->label('Enable guest access')
27+
->helperText('If enabled, users will not be required to login to access the frontend.'),
28+
]);
29+
}
30+
31+
public static function getCluster(): ?string
32+
{
33+
return app(CommonPlugin::class)->getSettingsCluster();
34+
}
35+
36+
public static function getNavigationLabel(): string
37+
{
38+
return 'Frontend';
39+
}
40+
41+
public function getTitle(): string|Htmlable
42+
{
43+
return $this->getNavigationLabel();
44+
}
45+
}

src/FrontendPlugin.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Eclipse\Frontend;
4+
5+
use Eclipse\Common\Foundation\Plugins\Plugin;
6+
7+
class FrontendPlugin extends Plugin
8+
{
9+
10+
}

src/FrontendServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public function configurePackage(SpatiePackage|Package $package): void
1616
$package->name(static::$name)
1717
->hasConfigFile()
1818
->hasTranslations()
19-
->hasViews();
19+
->hasViews()
20+
->hasSettings();
2021
}
2122

2223
public function register(): self

src/Settings/FrontendSettings.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Eclipse\Frontend\Settings;
4+
5+
use Spatie\LaravelSettings\Settings;
6+
7+
class FrontendSettings extends Settings
8+
{
9+
public bool $guest_access = false;
10+
11+
public static function group(): string
12+
{
13+
return 'frontend';
14+
}
15+
}

0 commit comments

Comments
 (0)