### Install Filament Fabricator via Composer
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Installs the Filament Fabricator package using Composer. Requires Filament Panels to be configured beforehand.
```bash
composer require z3d0x/filament-fabricator
```
--------------------------------
### Run Filament Fabricator Install Command
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Executes the Artisan command to publish the configuration and migrations for Filament Fabricator. This is a necessary step after installing the package via Composer.
```bash
php artisan filament-fabricator:install
```
--------------------------------
### Example Page Block Schema with TextInput
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
A simple example of a `getBlockSchema` implementation defining a schema with a single text input field.
```php
//Given the following schema
public static function getBlockSchema(): Block
{
return Block::make('my-block')
->schema([
TextInput::make('name'),
]);
}
```
--------------------------------
### Installing Filament Fabricator via Composer
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/README.md
Installs the Filament Fabricator package using Composer, downloading it into your project's dependencies.
```bash
composer require z3d0x/filament-fabricator
```
--------------------------------
### Running Filament Fabricator Installation Command
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/README.md
Executes the Artisan command provided by the Filament Fabricator package to complete the installation process, which may include publishing configuration or running migrations.
```bash
php artisan filament-fabricator:install
```
--------------------------------
### Example Mutate Data Implementation
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
An example implementation of `mutateData` that replaces the original data with a custom array, which will then be available as props in the Blade view.
```php
// `MyBlock.php`
public static function mutateData(array $data): array
{
return ['foo' => 'bar'];
}
```
--------------------------------
### Customizing PageResource Navigation
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Examples of using static methods on the `PageResource` class to customize its appearance and position in the Filament sidebar navigation.
```php
use Z3d0X\FilamentFabricator\Resources\PageResource;
PageResource::navigationGroup('Blog');
PageResource::navigationSort(1);
PageResource::navigationIcon('heroicon-o-cube');
```
--------------------------------
### Example Generated Layout Class
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Shows the structure of a generated Filament Fabricator Layout class. Layouts extend Z3d0X\FilamentFabricator\Layouts\Layout and define a static $name property used for identification.
```php
use Z3d0X\FilamentFabricator\Layouts\Layout;
class DefaultLayout extends Layout
{
protected static ?string $name = 'default';
}
```
--------------------------------
### Example Generated Layout Blade Component
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
The default Blade template generated for a new layout. It receives the $page variable and includes the filament-fabricator::page-blocks component to render the page content. It is wrapped in a base layout component by default.
```blade
@props(['page'])
{{-- Header Here --}}
{{-- Footer Here --}}
```
--------------------------------
### Setting PageBuilder Block Picker Style via configureUsing
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Example showing how to set the visual style of the block picker (e.g., Modal) for `PageBuilder` using the `blockPickerStyle` method within `configureUsing`.
```php
use Z3d0X\FilamentFabricator\Enums\BlockPickerStyle;
use Z3d0X\FilamentFabricator\Forms\Components\PageBuilder;
PageBuilder::configureUsing(function (PageBuilder $builder) {
$builder->blockPickerStyle(BlockPickerStyle::Modal);
});
```
--------------------------------
### Conditionally Showing Filament Builder Block
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Example demonstrating how to make a Filament Builder block visible only when a condition based on another field's value is met.
```php
Block::make('foo')
->visible(fn ($get) => $get('../layout') == 'special')
```
--------------------------------
### Accessing Mutated Data in Blade View
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Example showing how the data returned by the `mutateData` method is accessed as props in the block's Blade component.
```blade
{{--- `my-block.blade.php` --}}
@dump($foo) // 'bar'
```
--------------------------------
### Customize Base Layout with FilamentFabricator Facade
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Demonstrates how to use the FilamentFabricator facade within a ServiceProvider's boot method to inject custom meta tags, register scripts, register styles, and set a favicon for the base layout.
```php
use Z3d0X\FilamentFabricator\Facades\FilamentFabricator;
use Illuminate\Foundation\Vite;
use Illuminate\Support\HtmlString;
//Add custom tags (like `` & ``)
FilamentFabricator::pushMeta([
new HtmlString(''),
]);
//Register scripts
FilamentFabricator::registerScripts([
'https://unpkg.com/browse/tippy.js@6.3.7/dist/tippy.esm.js', //external url
mix('js/app.js'), //laravel-mix
app(Vite::class)('resources/css/app.js'), //vite
asset('js/app.js'), // asset from public folder
]);
//Register styles
FilamentFabricator::registerStyles([
'https://unpkg.com/tippy.js@6/dist/tippy.css', //external url
mix('css/app.css'), //laravel-mix
app(Vite::class)('resources/css/app.css'), //vite
asset('css/app.css'), // asset from public folder
]);
FilamentFabricator::favicon(asset('favicon.ico'));
```
--------------------------------
### Configuring PageBuilder using configureUsing
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Demonstrates using the static `configureUsing` method on `PageBuilder` to apply standard Filament Builder configurations globally to the PageBuilder field.
```php
use Z3d0X\FilamentFabricator\Forms\Components\PageBuilder;
PageBuilder::configureUsing(function (PageBuilder $builder) {
$builder->collapsible(); //You can use any method supported by the Builder field
});
```
--------------------------------
### Publishing Filament Assets
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/README.md
Publishes the necessary assets for the registered Filament plugins, including Filament Fabricator, making them available for the frontend.
```bash
php artisan filament:assets
```
--------------------------------
### Creating Filament Fabricator Page Block using Artisan
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Use this Artisan command to generate the necessary PHP class and Blade view files for a new Page Block.
```bash
php artisan filament-fabricator:block MyBlock
```
--------------------------------
### Publish Filament Assets
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Publishes the assets for all registered Filament plugins, including Filament Fabricator. This command is required after registering new plugins or making changes that affect assets.
```bash
php artisan filament:assets
```
--------------------------------
### Create New Filament Fabricator Layout
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Uses the Artisan command to generate a new Layout class and its corresponding Blade component file. Replace DefaultLayout with your desired layout name.
```bash
php artisan filament-fabricator:layout DefaultLayout
```
--------------------------------
### Registering Filament Fabricator Plugin in Panel Provider
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/README.md
Registers the FilamentFabricatorPlugin instance within your Filament Panel provider's `plugins()` method to enable the plugin's functionality in the panel.
```php
use Z3d0X\FilamentFabricator\FilamentFabricatorPlugin;
//..
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
FilamentFabricatorPlugin::make(),
]);
}
```
--------------------------------
### Register Filament Fabricator Plugin
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Registers the FilamentFabricatorPlugin instance within your Filament Panel provider's panel method. This activates the plugin for the specific panel. Requires importing the plugin class.
```php
use Z3d0X\FilamentFabricator\FilamentFabricatorPlugin;
//..
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
FilamentFabricatorPlugin::make(),
]);
}
```
--------------------------------
### Registering Page Policy for Authorization
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Register the `\Z3d0X\FilamentFabricator\Models\Page` model with its corresponding policy in your Laravel `AuthServiceProvider` to enable authorization checks.
```php
PagePolicy::class,
];
//...
}
```
--------------------------------
### Defining Page Block Schema Method Signature
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
The signature for the static method where you define the form fields and structure for your Page Block using Filament's Builder Block.
```php
public static function getBlockSchema(): Block
```
--------------------------------
### Filament Fabricator Page Block PHP Class Structure
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
The basic structure of a generated Page Block class, extending `PageBlock` and including static methods for defining the schema and mutating data.
```php
use Filament\Forms\Components\Builder\Block;
use Z3d0X\FilamentFabricator\PageBlocks\PageBlock;
class MyBlock extends PageBlock
{
public static function getBlockSchema(): Block
{
return Block::make('my-block')
->schema([
//
]);
}
public static function mutateData(array $data): array
{
return $data;
}
}
```
--------------------------------
### Setting PageBuilder Block Picker Style in Plugin
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
An alternative, one-liner method to set the block picker style by chaining the `blockPickerStyle` method when registering the `FilamentFabricatorPlugin` in your Panel provider.
```php
use Z3d0X\FilamentFabricator\Enums\BlockPickerStyle;
use Z3d0X\FilamentFabricator\FilamentFabricatorPlugin;
//..
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugins([
FilamentFabricatorPlugin::make()
->blockPickerStyle(BlockPickerStyle::Modal),
]);
}
```
--------------------------------
### Publishing Filament Fabricator Migrations - PHP Artisan
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/CHANGELOG.md
This command is used to publish the database migrations specific to the Filament Fabricator package. This is necessary to apply schema changes, such as fixing the unique slug constraint introduced in v2.1.0.
```bash
php artisan vendor:publish --tag=filament-fabricator-migrations
```
--------------------------------
### Mutating Page Block Data Method Signature
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
The signature for the static method used to transform or modify the raw block data before it is passed as props to the Blade component.
```php
//`$data` is the raw block data.
public static function mutateData(array $data): array
```
--------------------------------
### Accessing Parent Data in Blade Block View
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
Use the `@aware` Blade directive to access data from the parent component, such as the `$page` instance, within your block's Blade view.
```blade
{{-- `my-block.blade.php` --}}
@aware(['page']) {{-- make sure this line exists, in order to access `$page` --}}
@dump($page)
```
--------------------------------
### Accessing Raw Block Data in Blade View
Source: https://github.com/z3d0x/filament-fabricator/blob/2.x/docs/README.md
By default, the Blade component receives raw data from the schema fields as direct props.
```blade
{{-- Your blade component would receive the following props --}}
@dump($name)
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.