https://github.com/klisica/filament-builder-blocks
ποΈ A Simpler Web CMS Builder for Laravel Filament
https://github.com/klisica/filament-builder-blocks
cms filament laravel
Last synced: 6 months ago
JSON representation
ποΈ A Simpler Web CMS Builder for Laravel Filament
- Host: GitHub
- URL: https://github.com/klisica/filament-builder-blocks
- Owner: klisica
- License: mit
- Created: 2024-05-27T20:06:27.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-05T01:37:39.000Z (11 months ago)
- Last Synced: 2025-08-05T03:22:36.635Z (11 months ago)
- Topics: cms, filament, laravel
- Language: PHP
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Filament Builder Blocks
### ποΈ A Simpler Web CMS Builder for Laravel Filament
[](https://packagist.org/packages/klisica/filament-builder-blocks)
[](https://github.com/klisica/filament-builder-blocks/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[](https://packagist.org/packages/klisica/filament-builder-blocks)
[](https://github.com/klisica/filament-builder-blocks/blob/main/LICENSE)
## Create, manage & customize
By re-using Filament's [Builder Input](https://filamentphp.com/docs/3.x/forms/fields/builder) this package enables you to create **custom section blocks as PHP classes** (i.e. `DefaultHeader.php`) enabling you to use all features supported in Filament.
Each section block uses his own **blade view file** (i.e. `default-header.blade.php`) with support for dynamic data binded in PHP classes.
Another great helper functions that are ready-to-use:
- `renderSections(...)` - Returns a fully formatted HTML code for each section,
- `cleanup(...)` - Cleans unused attributes and values on store and update methods on filaments Create and Edit pages.
## Installation
1. Require the package via composer:
```bash
composer require klisica/filament-builder-blocks
```
2. Install it to publish the config file:
```bash
php artisan filament-builder-blocks:install
```
3. Open the `config/filament-builder-blocks.php` file and set the `path` value to root destination where you'll have you PHP classes (or leave it as it is).
4. Run make section command to create your first example section class with the blade view file:
```bash
php artisan make:section Hero
```
## Default folder structure example
Main section `Hero.php` will be displayed in builder dropdown, while child sections `ExampleHero.php` and `AdvancedHero.php` will be displayed as toggle buttons.
```
βββ app
β βββ Sections
β β βββ Header
β β β βββ ExampleHero.php
β β β βββ AdvancedHero.php
β β β
β β βββ Hero.php
```
Creating layouts for each section block component.
```
βββ resources
β βββ views
β β βββ sections
β β β βββ example-hero.blade.php
β β β βββ advanced-hero.blade.php
```
> [!NOTE]
> To be sure that on running the `cleanup()` helper your data won't be remove use the **`content.`** prefix on `make` input methods. This is used a handler to avoid storing inputs that you still need to show for descpritive purposes (i.e. Placeholder component). Take the `ExampleHero.php` as example:
```php
class ExampleHero extends AbstractSectionItemProvider
{
public function getFieldset(): Fieldset
{
return Fieldset::make($this->getName())
->schema([
Placeholder::make('contact_links')->columnSpanFull(), // Will get cleared out.
TextInput::make('content.heading'), // Will keep on save methods.
]);
}
}
```
Example for adding cleanup on some Filaments Resource Edit Page:
```php
protected function mutateFormDataBeforeSave(array $data): array
{
return (new FilamentBuilderBlocks)->cleanup($data);
}
```
## Rendering components
1. Build sections in controller:
```php
$sections = (new FilamentBuilderBlocks)->renderSections(
sections: $pages->content, // Page sections stored in content column
wrappingSections: $layout->content // Layout sections stored in content column (includes the `yield` field),
configs: ['page' => $page, 'layout' => $layout] // Can be whatever you need to bind in `blade.php` files
);
return view('dynamic')->with('sections', $sections);
```
2. Display them in a `dynamic.blade.php` (or whatever you name it) file:
```php
@foreach($sections as $section)
{!! $section !!}
@endforeach
```
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Credits
- [KrΕ‘evan Lisica](https://github.com/klisica)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.