PHP code example of haringsrob / filament-page-builder

1. Go to this page and download the library: Download haringsrob/filament-page-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

haringsrob / filament-page-builder example snippets


return [
];

return [
    'enablePreview' => true,
];


public static function getSharedFields(): array
{
    return ['show'];
}

public function form(): array
{
    return [
        TextInput::make('title'),
        Toggle::make('show')
    ];
}



namespace App\Models;

use Sevendays\FilamentPageBuilder\Models\Contracts\Blockable;
use Sevendays\FilamentPageBuilder\Models\Traits\HasBlocks;
use Illuminate\Database\Eloquent\Model;

class Page extends Model implements Blockable
{
    use HasBlocks;

    protected $fillable = [
        'title'
    ];
}


use Sevendays\FilamentPageBuilder\Forms\Components\BlockEditor;
use App\Filament\Blocks\DemoBlock;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            BlockEditor::make('blocks')
                ->blocks([ // You can add more blocks here.
                    DemoBlock::class,
                ])
                ->renderInView('blocks.preview'), // Optional: To render the preview in a different view.
        ]);
}

@foreach($page->blocks as $block)
    {!! \Sevendays\FilamentPageBuilder\Facades\BlockRenderer::renderBlock($block) !!}
@endforeach
bash
php artisan vendor:publish --tag="filament-page-builder-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="filament-page-builder-config"
bash
php artisan vendor:publish --tag="filament-page-builder-views"