PHP code example of carljanzell / filament-page-builder
1. Go to this page and download the library: Download carljanzell/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/ */
carljanzell / filament-page-builder example snippets
use CarlJanzell\FilamentPageBuilder\FilamentPageBuilderPlugin;
$panel->plugin(
FilamentPageBuilderPlugin::make()
->blocks([
HeroBlock::class,
RichTextBlock::class,
])
// Section, text, image, button, embed, spacer and divider ship with the package.
// Register a class with the same type() to replace one.
->recordModel(\App\Models\Page::class) // stored, unused by the canvas
->blocksAttribute('blocks'),
);
use CarlJanzell\FilamentPageBuilder\Concerns\HasBlocks;
class Page extends Model
{
use HasBlocks;
}
use CarlJanzell\FilamentPageBuilder\Filament\Pages\DesignPage as BaseDesignPage;
class DesignPage extends BaseDesignPage
{
protected static string $resource = PageResource::class;
}
public static function getPages(): array
{
return [
// …
'design' => DesignPage::route('/{record}/design'),
];
}
use CarlJanzell\FilamentPageBuilder\Contracts\InlineEditable;
use CarlJanzell\FilamentPageBuilder\Editable;
class HeroBlock implements PageBlock, InlineEditable
{
public static function editables(): array
{
return [
'heading' => Editable::text()->placeholder('Write a heading'),
'subheading' => Editable::text()->multiline(),
];
}
}
use CarlJanzell\FilamentPageBuilder\Contracts\PageBlock;
use Filament\Forms\Components\TextInput;
class HeroBlock implements PageBlock
{
public static function type(): string { return 'hero'; }
public static function label(): string { return 'Hero'; }
public static function icon(): ?string { return 'heroicon-o-photo'; }
public static function view(): string { return 'blocks.hero'; }
public static function fileFields(): array { return ['image']; }
public static function isVisible(): bool { return true; }
public static function schema(): array
{
return [
TextInput::make('heading')->