diff --git a/README.md b/README.md index 46665c9..9250b11 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,21 @@ php artisan vendor:publish --tag="admin-kit-pages-views" ## Usage ```php -$pages = new AdminKit\Pages(); -echo $pages->echoPhrase('Hello, AdminKit!'); +class AdminPanelProvider extends PanelProvider +{ + public function panel(Panel $panel): Panel + { + return $panel + ->default() + ->id('admin') + ->path('admin') + ... + ->plugins([ + ... + \AdminKit\Pages\FilamentPlugin::make(), + ]); + } +} ``` ## Testing diff --git a/composer.json b/composer.json index ee543a5..0b05cd7 100644 --- a/composer.json +++ b/composer.json @@ -17,16 +17,16 @@ ], "require": { "php": "^8.1", - "filament/filament": "^2.0", - "filament/spatie-laravel-translatable-plugin": "^2.0", - "ibecsystems/admin-kit-core": "^2.0", - "ibecsystems/admin-kit-navigation": "^2.0", - "ibecsystems/admin-kit-seo": "^2.0", + "filament/filament": "^3.0-stable", + "filament/spatie-laravel-translatable-plugin": "^3.0-stable", + "ibecsystems/admin-kit-core": "^3.1", + "ibecsystems/admin-kit-navigation": "^3.0", + "ibecsystems/admin-kit-seo": "^3.0", "illuminate/contracts": "^10.0", "spatie/laravel-package-tools": "^1.14.0", "spatie/laravel-data": "^3.2", "spatie/laravel-json-api-paginate": "^1.13", - "spatie/laravel-query-builder": "^5.2", + "spatie/laravel-query-builder": "^5.7", "spatie/laravel-translatable": "^6.5" }, "require-dev": { diff --git a/src/FilamentPlugin.php b/src/FilamentPlugin.php new file mode 100644 index 0000000..d27b834 --- /dev/null +++ b/src/FilamentPlugin.php @@ -0,0 +1,31 @@ +resources([ + PageResource::class, + ]); + } + + public function boot(Panel $panel): void + { + } + + public static function make(): static + { + return app(static::class); + } +} diff --git a/src/PagesServiceProvider.php b/src/PagesServiceProvider.php index 58aa5a9..01ffbe0 100644 --- a/src/PagesServiceProvider.php +++ b/src/PagesServiceProvider.php @@ -2,14 +2,9 @@ namespace AdminKit\Pages; +use Spatie\LaravelPackageTools\Package; use AdminKit\Pages\Commands\PagesCommand; -use AdminKit\Pages\Models\Page; -use AdminKit\Pages\Providers\FilamentServiceProvider; use AdminKit\Pages\Providers\RouteServiceProvider; -use Filament\Forms\Components\Select; -use Filament\Forms\Components\TextInput; -use RyanChandler\FilamentNavigation\Facades\FilamentNavigation; -use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; class PagesServiceProvider extends PackageServiceProvider @@ -31,23 +26,6 @@ public function configurePackage(Package $package): void public function registeringPackage() { - $this->app->register(FilamentServiceProvider::class); $this->app->register(RouteServiceProvider::class); } - - public function packageBooted() - { - FilamentNavigation::addItemType(__('filament-navigation.attributes.page'), [ - Select::make('page_id') - ->label(__('filament-navigation.attributes.page_id')) - ->searchable() - ->options(function () { - return Page::pluck('title', 'id'); - }), - - TextInput::make('slug') - ->required() - ->label('slug'), - ]); - } } diff --git a/src/Providers/FilamentServiceProvider.php b/src/Providers/FilamentServiceProvider.php deleted file mode 100644 index 421d934..0000000 --- a/src/Providers/FilamentServiceProvider.php +++ /dev/null @@ -1,17 +0,0 @@ -schema([ - Forms\Components\Card::make([ + Forms\Components\Section::make([ Forms\Components\TextInput::make('page_title') ->label('Название страницы') ->required() @@ -45,7 +43,7 @@ function (string $context, $state, callable $set) { } ), Forms\Components\TextInput::make('slug') - ->disabled() + ->readOnly() ->required() ->unique(Page::class, 'slug', ignoreRecord: true), ])->columns(), @@ -62,7 +60,7 @@ function (string $context, $state, callable $set) { ]); } - public static function table(Table $table): Table + public static function table(Tables\Table $table): Tables\Table { return $table ->columns([ diff --git a/src/UI/Filament/Resources/PageResource/Pages/EditPage.php b/src/UI/Filament/Resources/PageResource/Pages/EditPage.php index 03409da..10bf599 100644 --- a/src/UI/Filament/Resources/PageResource/Pages/EditPage.php +++ b/src/UI/Filament/Resources/PageResource/Pages/EditPage.php @@ -3,17 +3,18 @@ namespace AdminKit\Pages\UI\Filament\Resources\PageResource\Pages; use AdminKit\Pages\UI\Filament\Resources\PageResource; -use Filament\Pages\Actions; +use Filament\Actions; use Filament\Resources\Pages\EditRecord; class EditPage extends EditRecord { protected static string $resource = PageResource::class; - protected function getActions(): array + protected function getHeaderActions(): array { return [ Actions\DeleteAction::make(), + Actions\RestoreAction::make(), ]; } } diff --git a/src/UI/Filament/Resources/PageResource/Pages/ListPage.php b/src/UI/Filament/Resources/PageResource/Pages/ListPage.php index 7fe684c..38f5681 100644 --- a/src/UI/Filament/Resources/PageResource/Pages/ListPage.php +++ b/src/UI/Filament/Resources/PageResource/Pages/ListPage.php @@ -3,14 +3,14 @@ namespace AdminKit\Pages\UI\Filament\Resources\PageResource\Pages; use AdminKit\Pages\UI\Filament\Resources\PageResource; -use Filament\Pages\Actions; +use Filament\Actions; use Filament\Resources\Pages\ListRecords; class ListPage extends ListRecords { protected static string $resource = PageResource::class; - protected function getActions(): array + protected function getHeaderActions(): array { return [ Actions\CreateAction::make(),