PHP code example of fayne / laravel-filament-page-builder

1. Go to this page and download the library: Download fayne/laravel-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/ */

    

fayne / laravel-filament-page-builder example snippets


use Fayne\PageBuilder\Contracts\ContentDefinitionRepository;
use Fayne\PageBuilder\Filament\Forms\Components\ContentBuilder;

$definitions = new class implements ContentDefinitionRepository
{
    public function fields(string $layout, bool $widget = false): array
    {
        return $layout === 'hero' ? [
            ['name' => 'heading', 'title' => 'Heading', 'resolver' => 'text'],
        ] : [];
    }
};

ContentBuilder::make('components')
    ->definitions($definitions, ['hero' => 'Hero']);

use Fayne\PageBuilder\Support\EloquentContentDefinitions;

$definitions = new EloquentContentDefinitions(
    config('filament-page.models.page_component'),
    config('filament-page.models.page_widget'),
);

ContentBuilder::make('components')->definitions(
    $definitions,
    $definitions->layouts(),
    $definitions->layouts(true),
);

use Fayne\PageBuilder\Support\ContentOutputResolver;

$projection = app(ContentOutputResolver::class)->resolve(
    $storedContent,
    $definitions,
    connection: $connectionName,
    locale: 'en',
);

// config/filament-page-builder.php
'http' => ['endpoints' => [
    'https://content.example.com/data' => [
        'methods' => ['GET'],
        'public' => true,
    ],
]],