- Install spatie/laravel-permission v6.24 with 3 roles (admin, editor, viewer) and 5 base permissions - Install owen-it/laravel-auditing v14.0 for tracking model changes - Install laravel/sanctum v4.3 for API token authentication - Install spatie/laravel-ignition v2.11 and spatie/flare-client-php v1.10 for enhanced error tracking - Add Module System with make:module artisan command for scaffolding features - Create Site Settings page in Filament admin for logo, colors, and configuration - Add comprehensive debugging documentation (DEBUGGING.md, AI_CONTEXT.md updates) - Create FEATURES.md with complete feature reference - Update User model with HasRoles and HasApiTokens traits - Configure Redis cache and OPcache for performance - Add RolePermissionSeeder with pre-configured roles and permissions - Update documentation with debugging-first workflow - All features pre-installed and production-ready
95 lines
2.6 KiB
Markdown
95 lines
2.6 KiB
Markdown
# Module System
|
|
|
|
This Laravel application uses a modular architecture to organize features into self-contained modules.
|
|
|
|
## Creating a New Module
|
|
|
|
Use the artisan command to scaffold a complete module:
|
|
|
|
```bash
|
|
php artisan make:module ProductCatalog
|
|
```
|
|
|
|
This creates:
|
|
- **Model**: `app/Modules/ProductCatalog/Models/ProductCatalog.php`
|
|
- **Controller**: `app/Modules/ProductCatalog/Controllers/ProductCatalogController.php`
|
|
- **Routes**: `app/Modules/ProductCatalog/routes.php`
|
|
- **Views**: `app/Modules/ProductCatalog/Views/`
|
|
- **Migration**: `database/migrations/YYYY_MM_DD_HHMMSS_create_product_catalogs_table.php`
|
|
- **Filament Resource**: `app/Filament/Resources/ProductCatalogResource.php`
|
|
- **Tests**: `tests/Modules/ProductCatalog/ProductCatalogTest.php`
|
|
|
|
## Module Structure
|
|
|
|
```
|
|
app/Modules/
|
|
└── ProductCatalog/
|
|
├── Models/
|
|
│ └── ProductCatalog.php
|
|
├── Controllers/
|
|
│ └── ProductCatalogController.php
|
|
├── Views/
|
|
│ ├── index.blade.php
|
|
│ ├── create.blade.php
|
|
│ ├── edit.blade.php
|
|
│ └── show.blade.php
|
|
└── routes.php
|
|
```
|
|
|
|
## Registering Module Routes
|
|
|
|
After creating a module, register its routes in `routes/web.php`:
|
|
|
|
```php
|
|
require __DIR__.'/../app/Modules/ProductCatalog/routes.php';
|
|
```
|
|
|
|
## Module Features
|
|
|
|
Each module includes:
|
|
|
|
✅ **CRUD Operations** - Full Create, Read, Update, Delete functionality
|
|
✅ **Authentication** - Routes protected by auth middleware
|
|
✅ **Filament Admin** - Auto-generated admin panel resource
|
|
✅ **Blade Views** - Responsive Tailwind CSS templates
|
|
✅ **Tests** - Pest test suite for module functionality
|
|
✅ **Permissions** - Ready for role-based access control
|
|
|
|
## Example Usage
|
|
|
|
```bash
|
|
# Create an Inventory module
|
|
php artisan make:module Inventory
|
|
|
|
# Run migrations
|
|
php artisan migrate
|
|
|
|
# Register routes in routes/web.php
|
|
require __DIR__.'/../app/Modules/Inventory/routes.php';
|
|
|
|
# Access at: http://localhost:8080/inventory
|
|
# Admin panel: http://localhost:8080/admin/inventories
|
|
```
|
|
|
|
## Adding Permissions
|
|
|
|
To add module-specific permissions:
|
|
|
|
```php
|
|
// In database/seeders/RolePermissionSeeder.php
|
|
$permissions = [
|
|
'inventory.view',
|
|
'inventory.create',
|
|
'inventory.edit',
|
|
'inventory.delete',
|
|
];
|
|
```
|
|
|
|
## Best Practices
|
|
|
|
1. **Keep modules self-contained** - Each module should be independent
|
|
2. **Use namespaces** - Follow the `App\Modules\{ModuleName}` pattern
|
|
3. **Test your modules** - Run `php artisan test` after creating
|
|
4. **Document changes** - Update module README if you modify structure
|
|
5. **Use Filament** - Leverage the admin panel for quick CRUD interfaces
|