Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filament Support #67

Open
AshrafBasry opened this issue Feb 14, 2024 · 1 comment
Open

Filament Support #67

AshrafBasry opened this issue Feb 14, 2024 · 1 comment

Comments

@AshrafBasry
Copy link

Is there will be support for filament commands like php artisan make:filament-panel Admin --module=Module ?
#51

@WebKenth
Copy link
Contributor

WebKenth commented May 5, 2024

Just my 5 cents here

if you create a FilamentPlugin file filament will automatically handle your app-modules

You can make a FilamentPlugin file in app-modules/<your-module>/src

Example file:

<?php

namespace Vendor\Module;

use Filament\Contracts\Plugin;
use Filament\Panel;

class <MODULE>FilamentPlugin implements Plugin
{

    public static function make(): static
    {
        return app(static::class);
    }

    public function getId(): string
    {
        return 'vendor-module';
    }

    public function register(Panel $panel): void
    {
        $panel->discoverResources(in: base_path('app-modules/<your-module>/src/Filament/Resources'), for: 'VENDOR\\MODULE\\Filament\\Resources');
    }

    public function boot(Panel $panel): void
    {
        //
    }

    public static function get(): static
    {
        /** @var static $plugin */
        $plugin = filament(app(static::class)->getId());

        return $plugin;
    }
}

Then add this to your panel in the ->plugins([ \<VENDOR>\<MODULE>\<MODULE>FilamentPlugin::make() ]) array

Any filament command like php artisan make:filament-resource Customer will now ask you where you want to make it and if you pick your plugin it auto places it in to the module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants