From 7a85ccab54491c0fe1b2913f90714f22ab69587d Mon Sep 17 00:00:00 2001 From: daurensky Date: Mon, 12 Feb 2024 11:20:45 +0600 Subject: [PATCH] feat: support filament v3 --- README.md | 17 ++++++++-- composer.json | 8 ++--- src/DocumentsServiceProvider.php | 2 -- src/FilamentPlugin.php | 31 +++++++++++++++++++ src/Providers/FilamentServiceProvider.php | 17 ---------- .../Filament/Resources/DocumentResource.php | 8 ++--- .../DocumentResource/Pages/CreateDocument.php | 4 +-- .../DocumentResource/Pages/EditDocument.php | 4 +-- .../DocumentResource/Pages/ListDocument.php | 4 +-- 9 files changed, 59 insertions(+), 36 deletions(-) create mode 100644 src/FilamentPlugin.php delete mode 100644 src/Providers/FilamentServiceProvider.php diff --git a/README.md b/README.md index 8f6c591..494712e 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,21 @@ php artisan vendor:publish --tag="admin-kit-documents-views" ## Usage ```php -$documents = new AdminKit\Documents(); -echo $documents->echoPhrase('Hello, AdminKit!'); +class AdminPanelProvider extends PanelProvider +{ + public function panel(Panel $panel): Panel + { + return $panel + ->default() + ->id('admin') + ->path('admin') + ... + ->plugins([ + ... + \AdminKit\Documents\FilamentPlugin::make(), + ]); + } +} ``` ## Testing diff --git a/composer.json b/composer.json index e4f7052..1854093 100644 --- a/composer.json +++ b/composer.json @@ -17,14 +17,14 @@ ], "require": { "php": "^8.1", - "filament/filament": "^2.0", - "filament/spatie-laravel-translatable-plugin": "^2.0", - "ibecsystems/admin-kit-core": "^2.0", + "filament/filament": "^3.0-stable", + "filament/spatie-laravel-translatable-plugin": "^3.2", + "ibecsystems/admin-kit-core": "^3.1", "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/DocumentsServiceProvider.php b/src/DocumentsServiceProvider.php index 19bf698..bdd6070 100644 --- a/src/DocumentsServiceProvider.php +++ b/src/DocumentsServiceProvider.php @@ -3,7 +3,6 @@ namespace AdminKit\Documents; use AdminKit\Documents\Commands\DocumentsCommand; -use AdminKit\Documents\Providers\FilamentServiceProvider; use AdminKit\Documents\Providers\RouteServiceProvider; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; @@ -28,7 +27,6 @@ public function configurePackage(Package $package): void public function registeringPackage() { - $this->app->register(FilamentServiceProvider::class); $this->app->register(RouteServiceProvider::class); } } diff --git a/src/FilamentPlugin.php b/src/FilamentPlugin.php new file mode 100644 index 0000000..006eeff --- /dev/null +++ b/src/FilamentPlugin.php @@ -0,0 +1,31 @@ +resources([ + DocumentResource::class, + ]); + } + + public function boot(Panel $panel): void + { + } + + public static function make(): static + { + return app(static::class); + } +} diff --git a/src/Providers/FilamentServiceProvider.php b/src/Providers/FilamentServiceProvider.php deleted file mode 100644 index 9b6d154..0000000 --- a/src/Providers/FilamentServiceProvider.php +++ /dev/null @@ -1,17 +0,0 @@ -schema([ @@ -30,7 +28,7 @@ public static function form(Form $form): Form ->columns(1); } - 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/DocumentResource/Pages/CreateDocument.php b/src/UI/Filament/Resources/DocumentResource/Pages/CreateDocument.php index 9311cd8..6b99722 100644 --- a/src/UI/Filament/Resources/DocumentResource/Pages/CreateDocument.php +++ b/src/UI/Filament/Resources/DocumentResource/Pages/CreateDocument.php @@ -3,7 +3,7 @@ namespace AdminKit\Documents\UI\Filament\Resources\DocumentResource\Pages; use AdminKit\Documents\UI\Filament\Resources\DocumentResource; -use Filament\Pages\Actions; +use Filament\Actions; use Filament\Resources\Pages\CreateRecord; class CreateDocument extends CreateRecord @@ -12,7 +12,7 @@ class CreateDocument extends CreateRecord protected static string $resource = DocumentResource::class; - protected function getActions(): array + protected function getHeaderActions(): array { return [ Actions\LocaleSwitcher::make(), diff --git a/src/UI/Filament/Resources/DocumentResource/Pages/EditDocument.php b/src/UI/Filament/Resources/DocumentResource/Pages/EditDocument.php index faf827e..27f102e 100644 --- a/src/UI/Filament/Resources/DocumentResource/Pages/EditDocument.php +++ b/src/UI/Filament/Resources/DocumentResource/Pages/EditDocument.php @@ -3,7 +3,7 @@ namespace AdminKit\Documents\UI\Filament\Resources\DocumentResource\Pages; use AdminKit\Documents\UI\Filament\Resources\DocumentResource; -use Filament\Pages\Actions; +use Filament\Actions; use Filament\Resources\Pages\EditRecord; class EditDocument extends EditRecord @@ -12,7 +12,7 @@ class EditDocument extends EditRecord protected static string $resource = DocumentResource::class; - protected function getActions(): array + protected function getHeaderActions(): array { return [ Actions\LocaleSwitcher::make(), diff --git a/src/UI/Filament/Resources/DocumentResource/Pages/ListDocument.php b/src/UI/Filament/Resources/DocumentResource/Pages/ListDocument.php index fab71d1..121f346 100644 --- a/src/UI/Filament/Resources/DocumentResource/Pages/ListDocument.php +++ b/src/UI/Filament/Resources/DocumentResource/Pages/ListDocument.php @@ -3,7 +3,7 @@ namespace AdminKit\Documents\UI\Filament\Resources\DocumentResource\Pages; use AdminKit\Documents\UI\Filament\Resources\DocumentResource; -use Filament\Pages\Actions; +use Filament\Actions; use Filament\Resources\Pages\ListRecords; class ListDocument extends ListRecords @@ -12,7 +12,7 @@ class ListDocument extends ListRecords protected static string $resource = DocumentResource::class; - protected function getActions(): array + protected function getHeaderActions(): array { return [ Actions\LocaleSwitcher::make(),