diff --git a/composer.json b/composer.json index 193ddaa..cacdd56 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "php": "^8.1", "ext-json": "*", "doctrine/dbal": "^3.5.1", - "ryangjchandler/filament-navigation": "dev-filament3", + "ryangjchandler/filament-navigation": "^1.0", "filament/spatie-laravel-media-library-plugin": "^3.0@beta", "filament/spatie-laravel-tags-plugin": "^3.0@beta", "spatie/laravel-medialibrary": "^10.0.0", @@ -87,11 +87,5 @@ ] } }, - "minimum-stability": "dev", - "repositories": [ - { - "type": "git", - "url": "git@github.com:atmonshi/filament-navigation.git" - } - ] + "minimum-stability": "dev" } diff --git a/src/SkyPlugin.php b/src/SkyPlugin.php index 6a26fd9..bfff6af 100644 --- a/src/SkyPlugin.php +++ b/src/SkyPlugin.php @@ -3,12 +3,14 @@ namespace LaraZeus\Sky; use Filament\Contracts\Plugin; +use Filament\Forms\Components\Select; use Filament\Panel; use LaraZeus\Sky\Filament\Resources\FaqResource; use LaraZeus\Sky\Filament\Resources\LibraryResource; use LaraZeus\Sky\Filament\Resources\PageResource; use LaraZeus\Sky\Filament\Resources\PostResource; use LaraZeus\Sky\Filament\Resources\TagResource; +use RyanChandler\FilamentNavigation\FilamentNavigation; class SkyPlugin implements Plugin { @@ -38,6 +40,34 @@ public function register(Panel $panel): void } $panel->resources([TagResource::class]); + + $panel->plugin( + FilamentNavigation::make() + ->itemType(__('Post link'), [ + Select::make('post_id') + ->label(__('Select Post')) + ->searchable() + ->options(function () { + return SkyPlugin::get()->getPostModel()::published()->pluck('title', 'id'); + }), + ]) + ->itemType(__('Page link'), [ + Select::make('page_id') + ->label(__('Select Page')) + ->searchable() + ->options(function () { + return SkyPlugin::get()->getPostModel()::page()->pluck('title', 'id'); + }), + ]) + ->itemType(__('Library link'), [ + Select::make('library_id') + ->label(__('Select Library')) + ->searchable() + ->options(function () { + return SkyPlugin::get()->getTagModel()::getWithType('library')->pluck('name', 'id'); + }), + ]) + ); } public static function make(): static @@ -45,7 +75,7 @@ public static function make(): static return app(static::class); } - public static function get(): Plugin | \Filament\FilamentManager + public static function get(): Plugin|\Filament\FilamentManager { return filament(app(static::class)->getId()); } diff --git a/src/SkyServiceProvider.php b/src/SkyServiceProvider.php index 8df7fec..8c6643b 100644 --- a/src/SkyServiceProvider.php +++ b/src/SkyServiceProvider.php @@ -3,11 +3,9 @@ namespace LaraZeus\Sky; use Filament\Facades\Filament; -use Filament\Forms\Components\Select; use LaraZeus\Core\CoreServiceProvider; use LaraZeus\Sky\Console\migrateCommand; use LaraZeus\Sky\Console\PublishCommand; -use RyanChandler\FilamentNavigation\Facades\FilamentNavigation; use RyanChandler\FilamentNavigation\Filament\Resources\NavigationResource; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; @@ -62,43 +60,15 @@ protected function getMigrations(): array private function bootFilamentNavigation(): void { - if (! array_key_exists('zeus-sky', app('filament')->getCurrentPanel()->getPlugins())) { + if (!app('filament')->hasPlugin('zeus-sky')) { return; } + NavigationResource::navigationGroup(SkyPlugin::get()->getNavigationGroupLabel()); NavigationResource::navigationSort(999); - + NavigationResource::navigationIcon('heroicon-o-queue-list'); NavigationResource::navigationLabel(__('Navigations')); NavigationResource::pluralLabel(__('Navigations')); NavigationResource::label(__('Navigation')); - - NavigationResource::navigationIcon('heroicon-o-queue-list'); - - FilamentNavigation::addItemType(__('Post link'), [ - Select::make('post_id') - ->label(__('Select Post')) - ->searchable() - ->options(function () { - return SkyPlugin::get()->getPostModel()::published()->pluck('title', 'id'); - }), - ]); - - FilamentNavigation::addItemType(__('Page link'), [ - Select::make('page_id') - ->label(__('Select Page')) - ->searchable() - ->options(function () { - return SkyPlugin::get()->getPostModel()::page()->pluck('title', 'id'); - }), - ]); - - FilamentNavigation::addItemType(__('Library link'), [ - Select::make('library_id') - ->label(__('Select Library')) - ->searchable() - ->options(function () { - return SkyPlugin::get()->getTagModel()::getWithType('library')->pluck('name', 'id'); - }), - ]); } }