softok2/filament-page-builder

This is my package filament-page-builder

0.0.7 2024-05-21 21:55 UTC

This package is auto-updated.

Last update: 2024-05-21 21:57:13 UTC


README

# Filament tool for improve management of pages content speed and easy

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package comes with predefined form components that can be used to build a page:

  • Text
  • ImageUpload
  • TextBox
  • Marquee
  • Slider

Installation

You can install the package via composer:

composer require softok2/filament-page-builder

You can set up all the necessary files by running the following command:

php artisan filament-page-builder:install

And it is ready to use!!

Usage

Its recommended to run migrations and seeders to get the default components and pages.

php artisan migrate --seed

The packages come with a predefined page blocks and layout components in App//Filament//PageBuilder . Page blocks look like this:

class HomeBlock extends PageBlock
{
    const HEADER_SECTION = 'header_section';

    public static string $fileUploadDirectory = 'uploads/pages/';

    public function headerSection(): Block
    {
        return Block::make(self::HEADER_SECTION)->label(__('Header Section'))
            ->schema([
                Text::make('title'),
                ImageUpload::make('background'),
            ])->maxItems(1);
    }
}

Define your own section per page declaring a method with the name and de Section suffix.

Include the plugins in your admin panel:

...
   ->plugins([
        FilamentPageBuilder::make()
])

Customization

Yoy can define your own blocks and components by creating both classes and mapping them in the plugin configuration.

For create a new block you can run the following command:

php artisan filament-page-builder-block:make HistoryBlock

For create a new layout component you can run the following command:

php artisan filament-page-builder-lc:make HeroComponent

Then you can map the new blocks and components in the plugin configuration:

FilamentPageBuilder::make()
            ->withPosts()
            ->blocksMapper([
                'history' => HistoryBlock::class,
            ])
            ->layoutsComponentsMapper([
                'hero' => HeroComponent::class,
            ])

In the example above, 'history' and 'hero' are the name of the page and component respectively. You can easly add them in the seeders:

  • PageSeeder.php
  • LayoutComponentSeeder.php

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.