environment('local'); } public static function shouldRegisterNavigation(): bool { return app()->environment('local'); } public function mount(): void { $this->form->fill([ 'create_git_branch' => true, 'include_api' => false, ]); $this->loadModules(); } public function loadModules(): void { $discovery = new ModuleDiscoveryService(); $this->modules = $discovery->discoverModules(); $this->summary = $discovery->getModuleSummary(); } public function toggleModule(string $moduleName): void { $this->expandedModule = $this->expandedModule === $moduleName ? null : $moduleName; } public function form(Form $form): Form { return $form ->schema([ Section::make('Module Details') ->description('Create a new module skeleton with all the necessary folders and files.') ->schema([ TextInput::make('name') ->label('Module Name') ->placeholder('e.g., Accounting, Inventory, HumanResources') ->helperText('Use PascalCase. This will create app/Modules/YourModuleName/') ->required() ->maxLength(50) ->rules(['regex:/^[A-Z][a-zA-Z0-9]*$/']) ->validationMessages([ 'regex' => 'Module name must be PascalCase (start with uppercase, letters and numbers only).', ]) ->live(onBlur: true) ->afterStateUpdated(fn ($state, callable $set) => $set('name', Str::studly($state)) ), Textarea::make('description') ->label('Description') ->placeholder('Brief description of what this module does...') ->rows(2) ->maxLength(255), ]), Section::make('Options') ->schema([ Toggle::make('create_git_branch') ->label('Create Git Branch') ->helperText('Automatically create and checkout a new branch: module/{module-name}') ->default(true), Toggle::make('include_api') ->label('Include API Routes') ->helperText('Add Routes/api.php with Sanctum authentication') ->default(false), ]) ->columns(2), Section::make('What Will Be Created') ->schema([ \Filament\Forms\Components\Placeholder::make('structure') ->label('') ->content(fn () => new \Illuminate\Support\HtmlString('
app/Modules/{ModuleName}/
├── Config/{module_name}.php
├── Database/Migrations/
├── Database/Seeders/
├── Filament/Resources/
├── Http/Controllers/{ModuleName}Controller.php
├── Http/Middleware/
├── Http/Requests/
├── Models/
├── Policies/
├── Services/
├── Routes/web.php
├── Resources/views/index.blade.php
├── Permissions.php
├── {ModuleName}ServiceProvider.php
└── README.md
')), ]) ->collapsible() ->collapsed(), ]) ->statePath('data'); } public function generate(): void { $data = $this->form->getState(); $service = new ModuleGeneratorService(); $this->result = $service->generate($data['name'], [ 'description' => $data['description'] ?? '', 'create_git_branch' => $data['create_git_branch'] ?? true, 'include_api' => $data['include_api'] ?? false, ]); if ($this->result['success']) { Notification::make() ->title('Module Created Successfully!') ->body("Module {$this->result['module_name']} has been created.") ->success() ->persistent() ->send(); // Reset form for next module $this->form->fill([ 'name' => '', 'description' => '', 'create_git_branch' => true, 'include_api' => false, ]); // Reload modules list $this->loadModules(); } else { Notification::make() ->title('Module Creation Failed') ->body($this->result['message']) ->danger() ->persistent() ->send(); } } public function clearResult(): void { $this->result = null; } }