From f3954710521bbb6b83b660f20af163cefda8db28 Mon Sep 17 00:00:00 2001 From: Fady Mondy Date: Mon, 16 Sep 2024 18:26:13 +0300 Subject: [PATCH] add filament-plugins integration --- module.json | 29 +++++++++++++++++++++++++++++ src/FilamentMediaManagerPlugin.php | 23 +++++++++++++++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 module.json diff --git a/module.json b/module.json new file mode 100644 index 0000000..4ade647 --- /dev/null +++ b/module.json @@ -0,0 +1,29 @@ +{ + "name": "FilamentMediaManager", + "alias": "filament-media-manager", + "description": { + "ar": "قم بادارة ملفات الوسائط الخاصة بك باستخدام مكتبة الوسائط من spatie بواجهة رسومية سهلة الاستخدام لـ FilamentPHP", + "en": "Manage your media files using spatie media library with easy to use GUI for FilamentPHP", + "gr": "Manage your media files using spatie media library with easy to use GUI for FilamentPHP", + "sp": "Manage your media files using spatie media library with easy to use GUI for FilamentPHP" + }, + "keywords": [], + "priority": 0, + "providers": [ + "TomatoPHP\\FilamentMediaManager\\FilamentMediaManagerServiceProvider" + ], + "files": [], + "title": { + "ar": "مدير الوسائط", + "en": "Media Manager", + "gr": "Media Manager", + "sp": "Media Manager" + }, + "color": "#cc1448", + "icon": "heroicon-c-photo", + "placeholder": "https://raw.githubusercontent.com/tomatophp/filament-media-manager/master/arts/3x1io-tomato-media-manager.jpg", + "type": "plugin", + "version": "v1.1.2", + "github" : "https://github.com/tomatophp/filament-media-manager", + "docs" : "https://github.com/tomatophp/filament-media-manager" +} diff --git a/src/FilamentMediaManagerPlugin.php b/src/FilamentMediaManagerPlugin.php index 71661a9..c161f00 100644 --- a/src/FilamentMediaManagerPlugin.php +++ b/src/FilamentMediaManagerPlugin.php @@ -4,6 +4,7 @@ use Filament\Contracts\Plugin; use Filament\Panel; +use Nwidart\Modules\Module; use TomatoPHP\FilamentArtisan\Pages\Artisan; use TomatoPHP\FilamentMediaManager\Pages\FoldersPage; use TomatoPHP\FilamentMediaManager\Resources\FolderResource; @@ -12,6 +13,9 @@ class FilamentMediaManagerPlugin implements Plugin { + private bool $isActive = false; + + public ?bool $allowSubFolders = false; public ?bool $allowUserAccess = false; @@ -34,10 +38,21 @@ public function allowUserAccess(bool $condation = true): static public function register(Panel $panel): void { - $panel->resources([ - FolderResource::class, - MediaResource::class - ]); + if(class_exists(Module::class)){ + if(\Nwidart\Modules\Facades\Module::find('FilamentMediaManager')->isEnabled()){ + $this->isActive = true; + } + } + else { + $this->isActive = true; + } + + if($this->isActive) { + $panel->resources([ + FolderResource::class, + MediaResource::class + ]); + } }