### Install Filament Blocks Builder via Composer
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/README.md
This command installs the Filament Blocks Builder plugin using Composer. Ensure you have Composer installed and configured for your PHP project.
```sh
composer require skyraptor/filament-blocks-builder
```
--------------------------------
### Run Migrations - Orchestral Testbench
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/README.md
This command executes the database migrations defined within the Orchestral Testbench environment. It ensures that the necessary database tables are created before proceeding with other setup steps.
```bash
vendor/bin/testbench migrate
```
--------------------------------
### Create Blade View for Custom Block
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/README.md
A simple Blade view to render the output of a custom block. The schema data, such as the 'description' field in this example, is accessible within the view.
```html
{{ $description }}
```
--------------------------------
### Complete Filament Resource with BlocksInput for Page Management
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Provides a full example of integrating BlocksInput into a Filament resource for managing pages. This includes defining the model, form schema, and using BlocksInput to handle block-based content.
```php
components([
Forms\Components\TextInput::make('title')
->required()
->maxLength(255),
Forms\Components\Section::make('Content')
->schema([
BlocksInput::make('content')
->blocks(fn() => [
Blocks\Card::block($schema),
Blocks\Typography\Heading::block($schema),
Blocks\Typography\Paragraph::block($schema),
])
->columnSpanFull()
]),
]);
}
}
```
--------------------------------
### Register Custom Block with BlocksInput
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/README.md
This code snippet demonstrates how to register a custom block, like 'App\Filament\Blocks\Example', within the BlocksInput component's configuration. This makes the custom block available for use in the form.
```php
->blocks(fn () => [
Blocks\Layout\Card::block($schema),
Blocks\Typography\Heading::block($schema),
Blocks\Typography\Paragraph::block($schema),
App\Filament\Blocks\Example::block($form)
// Add more Blocks!
])
```
--------------------------------
### Implement a Custom Filament Block
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/README.md
Shows how to create a custom block by extending the HTMLBlock contract and implementing the block() and view() methods. The block() method defines the form schema for the block's data, and the view() method specifies the Blade view for rendering.
```php
schema([
Components\Textarea::make('description')
->required(),
]);
}
public static function view(): ?string
{
return 'example';
}
}
```
--------------------------------
### Create Filament User - Orchestral Testbench
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/README.md
This command generates a Filament user within the Orchestral Testbench environment. This is necessary for testing Filament's user authentication and other related features.
```bash
vendor/bin/testbench make:filament-user
```
--------------------------------
### Typography Heading Block Configuration
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Configures the built-in heading block, allowing for selection of heading levels (h1-h6) and input for the heading content. It uses a text input for content and a select dropdown for the level.
```php
use SkyRaptor\FilamentBlocksBuilder\Blocks;
// Built-in heading block configuration
Blocks\Typography\Heading::block($schema)
->schema([
Components\TextInput::make('content')
->required(),
Components\Select::make('level')
->options([
'h1' => 'Heading 1',
'h2' => 'Heading 2',
'h3' => 'Heading 3',
'h4' => 'Heading 4',
'h5' => 'Heading 5',
'h6' => 'Heading 6',
])
->required()
])
```
--------------------------------
### Control Block Inheritance in BlocksInput
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Illustrates how to control block inheritance in nested BlocksInput components using the 'inherit' method. Setting 'inherit' to false prevents nested inputs from inheriting blocks from their parent.
```php
use SkyRaptor\FilamentBlocksBuilder\Forms\Components\BlocksInput;
use SkyRaptor\FilamentBlocksBuilder\Blocks;
// Disable inheritance for a specific BlocksInput
BlocksInput::make('sidebar_content')
->inherit(false)
->blocks(fn() => [
// Only these blocks will be available, no inheritance from parent
Blocks\Typography\Paragraph::block($schema),
])
```
--------------------------------
### Nested Blocks with Card Component in BlocksInput
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Demonstrates how the Card block supports nested BlocksInput, enabling complex hierarchical layouts. It shows how to define blocks within the Card block, including other typography blocks.
```php
use SkyRaptor\FilamentBlocksBuilder\Blocks;
use SkyRaptor\FilamentBlocksBuilder\Forms\Components\BlocksInput;
BlocksInput::make('content')
->blocks(fn() => [
// Card block supports nested blocks inside it
Blocks\Card::block($schema),
Blocks\Typography\Heading::block($schema),
Blocks\Typography\Paragraph::block($schema),
])
```
--------------------------------
### Generate SQLite Database - Orchestral Testbench
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/README.md
This command generates an empty, persistent SQLite database for the Laravel skeleton using Orchestral Testbench. This is a prerequisite for running migrations and creating Filament users within the test environment.
```bash
vendor/bin/testbench package:create-sqlite-db
```
--------------------------------
### Typography Paragraph Block with Markdown Support
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Configures the built-in paragraph block, which supports markdown editor for rich text content. This allows users to format text using markdown syntax.
```php
use SkyRaptor\FilamentBlocksBuilder\Blocks;
// Built-in paragraph block with markdown support
Blocks\Typography\Paragraph::block($schema)
->schema([
Components\MarkdownEditor::make('content')
->required(),
])
```
--------------------------------
### Configure Git for Long Paths on Windows
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/docs/CONTRIBUTING.md
This command updates the global Git configuration to allow for longer file paths, which can be a common issue on Windows systems, especially when using msys. This is a system-wide setting.
```bash
git config --system core.longpaths true
```
--------------------------------
### Programmatic Block Rendering with BlocksRenderer
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Renders blocks programmatically using the BlocksRenderer class. This is useful when direct control over the rendering process is required. It takes the block content as input and returns HTML, with error handling for invalid block types.
```php
use SkyRaptor\FilamentBlocksBuilder\BlocksRenderer;
use App\Models\Page;
$page = Page::find(1);
try {
$html = BlocksRenderer::render($page->content);
return response($html, 200)
->header('Content-Type', 'text/html');
} catch (\SkyRaptor\FilamentBlocksBuilder\Exceptions\InvalidBlockTypeException $e) {
return response()->json([
'error' => 'Invalid block type',
'message' => $e->getMessage()
], 400);
}
```
--------------------------------
### Model Configuration for BlocksInput Data
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Configures an Eloquent model to handle `BlocksInput` data as an array. This ensures correct serialization and deserialization of block content when interacting with the database. It requires defining the `content` attribute in the `$fillable` array and casting it to `array`.
```php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Page extends Model
{
protected $fillable = [
'title',
'content'
];
protected function casts(): array
{
return [
'content' => 'array',
];
}
}
```
--------------------------------
### Custom Block Blade Template for Rendering
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Creates the Blade view template for a custom block (e.g., `CallToAction`). This template receives block data as variables and defines the HTML structure for rendering the block's content on the frontend, utilizing Tailwind CSS for styling.
```blade
{{-- resources/views/blocks/call-to-action.blade.php --}}
```
--------------------------------
### BlocksInput Form Component for Filament
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Adds a blocks-based content builder to Filament forms, allowing users to construct layouts by arranging different block types. It utilizes the `BlocksInput` component and accepts an array of block definitions.
```php
use SkyRaptor\FilamentBlocksBuilder\Blocks;
use SkyRaptor\FilamentBlocksBuilder\Forms\Components\BlocksInput;
use Filament\Forms;
Forms\Components\TextInput::make('title')
->required()
->maxLength(255),
BlocksInput::make('content')
->blocks(fn() => [
Blocks\Card::block($schema),
Blocks\Typography\Heading::block($schema),
Blocks\Typography\Paragraph::block($schema)
])
```
--------------------------------
### Registering Custom Blocks with BlocksInput
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Registers custom blocks, such as `CallToAction`, alongside built-in blocks within the `BlocksInput` component. This makes the custom blocks available for use in the Filament form builder interface.
```php
use App\Filament\Blocks\CallToAction;
use SkyRaptor\FilamentBlocksBuilder\Blocks;
use SkyRaptor\FilamentBlocksBuilder\Forms\Components\BlocksInput;
BlocksInput::make('content')
->blocks(fn() => [
Blocks\Typography\Heading::block($schema),
Blocks\Typography\Paragraph::block($schema),
Blocks\Card::block($schema),
CallToAction::block($schema),
])
```
--------------------------------
### Add BlocksInput Component to Filament Form
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/README.md
Demonstrates how to add the BlocksInput form component to a Filament PHP resource or form. This component allows for flexible layout design using various block types.
```php
use SkyRaptor\FilamentBlocksBuilder\Blocks;
use SkyRaptor\FilamentBlocksBuilder\Forms\Components\BlocksInput;
BlocksInput::make('content')
->blocks(fn () => [
Blocks\Layout\Card::block($schema),
Blocks\Typography\Heading::block($schema),
Blocks\Typography\Paragraph::block($schema)
])
```
--------------------------------
### Rendering Blocks Content with Blade Directive
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Renders block content in Blade views using the `@blocks` directive. This directive iterates through the provided block data (e.g., `$page->content`) and renders each block using its associated template.
```blade
{{-- resources/views/pages/show.blade.php --}}
{{ $page->title }}
{{ $page->title }}
@blocks($page->content)
```
--------------------------------
### Custom Block Definition using HTMLBlock
Source: https://context7.com/bumbummen99/filament-blocks-builder/llms.txt
Defines a custom block by extending the `HTMLBlock` contract. This involves implementing the `block` method to define the form schema for the block and the `view` method to specify the associated Blade template for rendering.
```php
schema([
Components\TextInput::make('heading')
->required()
->maxLength(255),
Components\Textarea::make('description')
->required()
->rows(3),
Components\TextInput::make('button_text')
->required()
->default('Learn More'),
Components\TextInput::make('button_url')
->url()
->required()
])->columns(2);
}
public static function view(): ?string
{
return 'blocks.call-to-action';
}
}
```
--------------------------------
### Render Blocks in Blade View - Filament Blocks Builder
Source: https://github.com/bumbummen99/filament-blocks-builder/blob/master/README.md
This snippet demonstrates how to use the 'blocks' Blade directive to render content generated by the BlocksInput component within a Blade view. It assumes the model's 'content' attribute holds the BlocksInput data.
```blade
@blocks($model->content)
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.