From f60b8fadc26209f7b8272c576fe5f90624f27b48 Mon Sep 17 00:00:00 2001 From: daurensky Date: Mon, 12 Feb 2024 10:57:11 +0600 Subject: [PATCH] fix: support filament v3 --- README.md | 17 ++++++++-- composer.json | 6 ++-- resources/lang/en/articles.php | 1 - resources/lang/ru/articles.php | 1 - src/ArticlesServiceProvider.php | 4 +-- src/FilamentPlugin.php | 31 +++++++++++++++++++ src/Providers/FilamentServiceProvider.php | 17 ---------- src/UI/Filament/Resources/ArticleResource.php | 19 ++++-------- .../ArticleResource/Pages/EditArticle.php | 4 +-- .../ArticleResource/Pages/ListArticles.php | 4 +-- 10 files changed, 60 insertions(+), 44 deletions(-) create mode 100644 src/FilamentPlugin.php delete mode 100644 src/Providers/FilamentServiceProvider.php diff --git a/README.md b/README.md index 129f62e..43bfcd4 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,21 @@ php artisan vendor:publish --tag="admin-kit-articles-views" ## Usage ```php -$articles = new AdminKit\Articles(); -echo $articles->echoPhrase('Hello, AdminKit!'); +class AdminPanelProvider extends PanelProvider +{ + public function panel(Panel $panel): Panel + { + return $panel + ->default() + ->id('admin') + ->path('admin') + ... + ->plugins([ + ... + \AdminKit\Articles\FilamentPlugin::make(), + ]); + } +} ``` ## Testing diff --git a/composer.json b/composer.json index 61dd125..edb2d7b 100644 --- a/composer.json +++ b/composer.json @@ -21,12 +21,12 @@ "php": "^8.1", "cviebrock/eloquent-sluggable": "^10.0", "illuminate/contracts": "^10.0", - "ibecsystems/admin-kit-core": "^2.2", - "ibecsystems/admin-kit-seo": "^2.2", + "ibecsystems/admin-kit-core": "^3.1", + "ibecsystems/admin-kit-seo": "^3.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" }, "require-dev": { "laravel/pint": "^1.0", diff --git a/resources/lang/en/articles.php b/resources/lang/en/articles.php index a1c9d02..3f809fb 100644 --- a/resources/lang/en/articles.php +++ b/resources/lang/en/articles.php @@ -4,7 +4,6 @@ 'resource' => [ 'label' => 'News', 'plural_label' => 'News', - 'cropper_title' => 'Crop image', 'id' => 'ID', 'image' => 'Image', diff --git a/resources/lang/ru/articles.php b/resources/lang/ru/articles.php index afb0700..29556a9 100644 --- a/resources/lang/ru/articles.php +++ b/resources/lang/ru/articles.php @@ -4,7 +4,6 @@ 'resource' => [ 'label' => 'Новость', 'plural_label' => 'Новости', - 'cropper_title' => 'Обрезать изображение', 'id' => 'ID', 'image' => 'Изображение', diff --git a/src/ArticlesServiceProvider.php b/src/ArticlesServiceProvider.php index 20b5601..de5264d 100644 --- a/src/ArticlesServiceProvider.php +++ b/src/ArticlesServiceProvider.php @@ -2,10 +2,9 @@ namespace AdminKit\Articles; +use Spatie\LaravelPackageTools\Package; use AdminKit\Articles\Commands\ArticlesCommand; -use AdminKit\Articles\Providers\FilamentServiceProvider; use AdminKit\Articles\Providers\RouteServiceProvider; -use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; class ArticlesServiceProvider extends PackageServiceProvider @@ -29,6 +28,5 @@ public function configurePackage(Package $package): void public function registeringPackage() { $this->app->register(RouteServiceProvider::class); - $this->app->register(FilamentServiceProvider::class); } } diff --git a/src/FilamentPlugin.php b/src/FilamentPlugin.php new file mode 100644 index 0000000..7e76e72 --- /dev/null +++ b/src/FilamentPlugin.php @@ -0,0 +1,31 @@ +resources([ + ArticleResource::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 6c7e041..0000000 --- a/src/Providers/FilamentServiceProvider.php +++ /dev/null @@ -1,17 +0,0 @@ -label(__('admin-kit-articles::articles.resource.image')) ->image() ->required() ->columnSpan(2) + ->imageEditor() // image properties ->imageCropAspectRatio(config('admin-kit-articles.image.crop_aspect_ratio')) ->imageResizeTargetWidth(config('admin-kit-articles.image.resize_target_width')) ->imageResizeTargetHeight(config('admin-kit-articles.image.resize_target_height')) - ->imagePreviewHeight(config('admin-kit-articles.image.preview_height')) - - // cropper properties - ->modalHeading(__('admin-kit-articles::articles.resource.cropper_header')) - ->modalSize('2xl') - ->zoomable(false); + ->imagePreviewHeight(config('admin-kit-articles.image.preview_height')); } $rows[] = TranslatableTabs::make(fn ($locale) => Forms\Components\Tabs\Tab::make($locale) @@ -90,7 +83,7 @@ function (string $context, $state, callable $set) { return $form->schema($rows); } - 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/ArticleResource/Pages/EditArticle.php b/src/UI/Filament/Resources/ArticleResource/Pages/EditArticle.php index f3291fa..5fb3f25 100644 --- a/src/UI/Filament/Resources/ArticleResource/Pages/EditArticle.php +++ b/src/UI/Filament/Resources/ArticleResource/Pages/EditArticle.php @@ -3,14 +3,14 @@ namespace AdminKit\Articles\UI\Filament\Resources\ArticleResource\Pages; use AdminKit\Articles\UI\Filament\Resources\ArticleResource; -use Filament\Pages\Actions; +use Filament\Actions; use Filament\Resources\Pages\EditRecord; class EditArticle extends EditRecord { protected static string $resource = ArticleResource::class; - protected function getActions(): array + protected function getHeaderActions(): array { return [ Actions\DeleteAction::make(), diff --git a/src/UI/Filament/Resources/ArticleResource/Pages/ListArticles.php b/src/UI/Filament/Resources/ArticleResource/Pages/ListArticles.php index 6892cfb..49fb77a 100644 --- a/src/UI/Filament/Resources/ArticleResource/Pages/ListArticles.php +++ b/src/UI/Filament/Resources/ArticleResource/Pages/ListArticles.php @@ -3,14 +3,14 @@ namespace AdminKit\Articles\UI\Filament\Resources\ArticleResource\Pages; use AdminKit\Articles\UI\Filament\Resources\ArticleResource; -use Filament\Pages\Actions; +use Filament\Actions; use Filament\Resources\Pages\ListRecords; class ListArticles extends ListRecords { protected static string $resource = ArticleResource::class; - protected function getActions(): array + protected function getHeaderActions(): array { return [ Actions\CreateAction::make(),