|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a Laravel package that provides a CMS system with flexible content blocks for Filament. It extends the `statikbe/laravel-filament-flexible-content-blocks` package to create a complete page management system with routing, SEO, redirects, and tagging functionality. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Testing |
| 12 | +```bash |
| 13 | +# Run tests with Pest |
| 14 | +composer test |
| 15 | +# Run tests with coverage |
| 16 | +composer test-coverage |
| 17 | +``` |
| 18 | + |
| 19 | +### Code Quality |
| 20 | +```bash |
| 21 | +# Run PHPStan static analysis |
| 22 | +composer analyse |
| 23 | +# Format code with Laravel Pint |
| 24 | +composer format |
| 25 | +``` |
| 26 | + |
| 27 | +### Package Setup |
| 28 | +```bash |
| 29 | +# Prepare/discover package after composer changes |
| 30 | +composer prepare |
| 31 | +``` |
| 32 | + |
| 33 | +### Seeding |
| 34 | +```bash |
| 35 | +# Seed default pages and settings |
| 36 | +php artisan flexible-content-block-pages:seed |
| 37 | +``` |
| 38 | + |
| 39 | +## Architecture Overview |
| 40 | + |
| 41 | +### Core Models |
| 42 | +- **Page** (`src/Models/Page.php`): Main content model with flexible content blocks, multilingual support, SEO fields, and hierarchical structure (parent/child relationships up to 3 levels deep) |
| 43 | +- **Settings** (`src/Models/Settings.php`): Global CMS settings and configuration |
| 44 | +- **Redirect** (`src/Models/Redirect.php`): URL redirect management |
| 45 | +- **Tag/TagType** (`src/Models/Tag.php`, `src/Models/TagType.php`): Content tagging system |
| 46 | +- **Menu/MenuItem** (`src/Models/Menu.php`, `src/Models/MenuItem.php`): Hierarchical menu system with nested structure using kalnoy/nestedset |
| 47 | + |
| 48 | +### Key Components |
| 49 | +- **Filament Resources**: Located in `src/Resources/` - provide admin interface for all models |
| 50 | +- **Route Helpers**: `src/Routes/` handles URL generation for pages, including localized URLs via `LocalisedPageRouteHelper` |
| 51 | +- **Page Controller**: `src/Http/Controllers/PageController.php` handles frontend page rendering with SEO optimization |
| 52 | +- **Flexible Content Blocks**: Integrates with the parent package for flexible content building |
| 53 | + |
| 54 | +### Configuration |
| 55 | +- Main config: `config/filament-flexible-content-block-pages.php` |
| 56 | +- Key settings: models, table names, resources, panel configuration, SEO defaults, route helper selection |
| 57 | +- Template overrides can be configured via `page_templates` array |
| 58 | + |
| 59 | +### Content Block System |
| 60 | +Pages use the flexible content blocks system from the parent package, allowing: |
| 61 | +- Rich content building with various block types |
| 62 | +- Multilingual content support |
| 63 | +- Hero images and overview fields |
| 64 | +- SEO meta fields and social media optimization |
| 65 | + |
| 66 | +### Routing Architecture |
| 67 | +- Three-level hierarchical pages: grandparent → parent → child |
| 68 | +- Localized routing support via `mcamara/laravel-localization` |
| 69 | +- Custom route helpers for different URL patterns |
| 70 | +- Frontend routes registered via `FilamentFlexibleContentBlockPages::routes()` |
| 71 | + |
| 72 | +### Caching Strategy |
| 73 | +- SEO image dimensions cached for 8 hours (`PageController::CACHE_SEO_IMAGE_TTL`) |
| 74 | +- Taggable cache implementation in `src/Cache/TaggableCache.php` |
| 75 | + |
| 76 | +### Key Dependencies |
| 77 | +- Laravel Filament for admin interface |
| 78 | +- Spatie packages for tags, media library, and redirects |
| 79 | +- Laravel Localization for multilingual support |
| 80 | +- SEOTools for meta tag and OpenGraph management |
| 81 | +- kalnoy/nestedset for hierarchical menu structure |
| 82 | + |
| 83 | +## Menu Builder System (In Development) |
| 84 | + |
| 85 | +### Current Status |
| 86 | +The menu builder is partially implemented with the following components: |
| 87 | + |
| 88 | +**✅ Completed:** |
| 89 | +- Menu and MenuItem models with kalnoy/nestedset integration |
| 90 | +- Database migrations for menus and menu_items tables |
| 91 | +- MenuResource with basic CRUD operations |
| 92 | +- ManageMenuItems page with drag-and-drop tree interface |
| 93 | +- Alpine.js + SortableJS powered tree builder component |
| 94 | +- Translation support (EN/NL) |
| 95 | +- Configuration system with max depth settings |
| 96 | + |
| 97 | +**🚧 Remaining Tasks:** |
| 98 | +- MenuItem form/modal for adding and editing menu items |
| 99 | +- Linkable model integration (following call-to-action patterns) |
| 100 | +- Frontend helper methods and blade components for menu rendering |
| 101 | +- Validation and error handling |
| 102 | +- Proper nested set operations for reordering |
| 103 | + |
| 104 | +### Architecture |
| 105 | +- **Menu Model**: Simple container with name, code, and description |
| 106 | +- **MenuItem Model**: Nested set structure with linkable polymorphic relationships |
| 107 | +- **ManageMenuItems Page**: Dedicated interface for menu structure management |
| 108 | +- **Tree Builder Component**: Custom Filament field with Alpine.js interactions |
| 109 | + |
| 110 | +### Configuration |
| 111 | +```php |
| 112 | +'menu' => [ |
| 113 | + 'max_depth' => 2, // Configurable nesting level |
| 114 | +], |
| 115 | +``` |
| 116 | + |
| 117 | +## Common Development Patterns |
| 118 | + |
| 119 | +When extending this package: |
| 120 | +1. Models extend the flexible content blocks contracts and traits |
| 121 | +2. Resources follow Filament patterns with translatable support |
| 122 | +3. Use the facade `FilamentFlexibleContentBlockPages` to access configuration |
| 123 | +4. SEO handling follows a fallback pattern: page SEO → hero image → default settings |
| 124 | +5. Route generation uses the configured route helper class |
| 125 | +6. Menu items follow the linkable pattern for polymorphic relationships |
0 commit comments