Skip to content

Commit

Permalink
add filament-plugins integration
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Sep 16, 2024
1 parent cca76a5 commit be79470
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 15 deletions.
29 changes: 29 additions & 0 deletions module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "FilamentLocations",
"alias": "filament-locations",
"description": {
"ar": "بيانات الدول والمناطق مخزنة في قاعدة البيانات",
"en": "Database Seeds for Locations for FilamentPHP",
"gr": "Database Seeds for Locations for FilamentPHP",
"sp": "Database Seeds for Locations for FilamentPHP"
},
"keywords": [],
"priority": 0,
"providers": [
"TomatoPHP\\FilamentLocations\\FilamentLocationsServiceProvider"
],
"files": [],
"title": {
"ar": "المناطق",
"en": "Locations Seeder",
"gr": "Locations Seeder",
"sp": "Locations Seeder"
},
"color": "#cc1448",
"icon": "heroicon-c-globe-asia-australia",
"placeholder": "https://raw.githubusercontent.com/tomatophp/filament-locations/master/arts/3x1io-tomato-locations.jpg",
"type": "plugin",
"version": "v1.0.4",
"github" : "https://github.com/tomatophp/filament-locations",
"docs" : "https://github.com/tomatophp/filament-locations"
}
44 changes: 29 additions & 15 deletions src/FilamentLocationsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Filament\Contracts\Plugin;
use Filament\Panel;
use Illuminate\View\View;
use Nwidart\Modules\Module;
use TomatoPHP\FilamentLocations\Resources\AreaResource;
use TomatoPHP\FilamentLocations\Resources\CityResource;
use TomatoPHP\FilamentLocations\Resources\CountryResource;
Expand All @@ -14,31 +15,44 @@

class FilamentLocationsPlugin implements Plugin
{
private bool $isActive = false;

public function getId(): string
{
return 'filament-locations';
}

public function register(Panel $panel): void
{
$resources = [];
if(config('filament-locations.resources.city')){
$resources[] = CityResource::class;
}
if(config('filament-locations.resources.country')){
$resources[] = CountryResource::class;
}
if(config('filament-locations.resources.languages')){
$resources[] = LanguageResource::class;
if(class_exists(Module::class)){
if(\Nwidart\Modules\Facades\Module::find('FilamentLocations')->isEnabled()){
$this->isActive = true;
}
}
if(config('filament-locations.resources.currency')){
$resources[] = CurrencyResource::class;
}
if(config('filament-locations.resources.locations')){
$resources[] = LocationResource::class;
else {
$this->isActive = true;
}

$panel->resources($resources);
if($this->isActive) {
$resources = [];
if (config('filament-locations.resources.city')) {
$resources[] = CityResource::class;
}
if (config('filament-locations.resources.country')) {
$resources[] = CountryResource::class;
}
if (config('filament-locations.resources.languages')) {
$resources[] = LanguageResource::class;
}
if (config('filament-locations.resources.currency')) {
$resources[] = CurrencyResource::class;
}
if (config('filament-locations.resources.locations')) {
$resources[] = LocationResource::class;
}

$panel->resources($resources);
}
}

public function boot(Panel $panel): void
Expand Down

0 comments on commit be79470

Please sign in to comment.