PHP code example of cube-agency / filament-constructor

1. Go to this page and download the library: Download cube-agency/filament-constructor 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/ */

    

cube-agency / filament-constructor example snippets


php artisan filament-constructor:create-block DoubleText

namespace App\Filament\Constructor\Blocks;

use CubeAgency\FilamentConstructor\Constructor\Blocks\BlockRenderer;
use Filament\Forms\Components\Textarea;

class DoubleTextBlock extends BlockRenderer
{
    public function name(): string
    {
        return 'double_text';
    }

    public function title(): string
    {
        return __('DoubleText');
    }

    public function schema(): array
    {
        return [
            Textarea::make('first_text'),
            Textarea::make('second_text'),
        ];
    }
}

return [
    'blocks' => [
        'double_text' => \App\Filament\Constructor\Blocks\DoubleTextBlock::class,
    ],
];

use CubeAgency\FilamentConstructor\Filament\Forms\Components\Constructor;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            // ...
            Constructor::make('blocks'),
            // ...
        ]);
}

return [
    'blocks' => [
        'double_text' => \App\Filament\Constructor\Blocks\DoubleTextBlock::class,
    ],
    
    'image_blocks' => [
        'double_image' => \App\Filament\Constructor\Blocks\DoubleImageBlock::class,
    ],
];

use CubeAgency\FilamentConstructor\Filament\Forms\Components\Constructor;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            // ...
            Constructor::make('blocks')->use(config('filament-constructor.image_blocks')),
            // ...
        ]);
}

    public function title(): string
    {
        return __('Text block');
    }

   public function icon(): string
    {
        return 'heroicon-o-chat-bubble-left-right';
    }

   public function maxItems(): int
    {
        return 1;
    }

   public function columns(): int
    {
        return 6;
    }

   Constructor::make('blocks')
    ->collapsible()
    ->collapsed()
bash
php artisan vendor:publish --tag="filament-constructor-config"