generated from filamentphp/plugin-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Features: filament:install, module:make:filament-cluster and modu…
…le:make-filament-plugin commands - Added the Filament Installation command to add filament support to a module - Added a command to generate a Filament plugin in a module - Added a command to generate a Filament cluster in a module - Modified phpstan and removed database as it is not needed
- Loading branch information
1 parent
2561e68
commit 2e437b3
Showing
5 changed files
with
72 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Coolsam\Modules\Concerns; | ||
|
||
use Filament\Panel; | ||
use Nwidart\Modules\Facades\Module; | ||
|
||
trait ModuleFilamentPlugin | ||
{ | ||
abstract public function getModuleName(): string; | ||
|
||
public function getModule(): \Nwidart\Modules\Module | ||
{ | ||
return Module::findOrFail($this->getModuleName()); | ||
} | ||
|
||
public function register(Panel $panel): void | ||
{ | ||
$module = $this->getModule(); | ||
$useClusters = config('filament-modules.clusters.enabled', false); | ||
$panel->discoverPages( | ||
in: $module->appPath('Filament'.DIRECTORY_SEPARATOR.'Pages'), | ||
for: $module->appNamespace('\\Filament\\Pages') | ||
); | ||
$panel->discoverResources( | ||
in: $module->appPath('Filament'.DIRECTORY_SEPARATOR.'Resources'), | ||
for: $module->appNamespace('\\Filament\\Resources') | ||
); | ||
$panel->discoverWidgets( | ||
in: $module->appPath('Filament'.DIRECTORY_SEPARATOR.'Widgets'), | ||
for: $module->appNamespace('\\Filament\\Widgets') | ||
); | ||
|
||
$panel->discoverLivewireComponents( | ||
in: $module->appPath('Livewire'), | ||
for: $module->appNamespace('\\Livewire') | ||
); | ||
|
||
if ($useClusters) { | ||
$path = $module->appPath('Filament'.DIRECTORY_SEPARATOR.'Clusters'); | ||
$namespace = $module->appNamespace('\\Filament\\Clusters'); | ||
$panel->discoverClusters( | ||
in: $path, | ||
for: $namespace, | ||
); | ||
} | ||
} | ||
|
||
public static function make(): static | ||
{ | ||
return app(static::class); | ||
} | ||
|
||
public static function get(): static | ||
{ | ||
/** @var static $plugin */ | ||
$plugin = filament(app(static::class)->getId()); | ||
|
||
return $plugin; | ||
} | ||
} |