定制 klisica/filament-builder-blocks 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

klisica/filament-builder-blocks

最新稳定版本:v1.0.0

Composer 安装命令:

composer require klisica/filament-builder-blocks

包简介

Flexible builder blocks generator for Filament

README 文档

README

🏗️ A Simpler Web CMS Builder for Laravel Filament

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

Create, manage & customize

By re-using Filament's Builder Input this package enables you to create custom section blocks as PHP classes (i.e. DefaultHeader.php) enabling you to use all features supported in Filament.

Each section block uses his own blade view file (i.e. default-header.blade.php) with support for dynamic data binded in PHP classes.

Another great helper functions that are ready-to-use:

  • renderSections(...) - Returns a fully formatted HTML code for each section,
  • cleanup(...) - Cleans unused attributes and values on store and update methods on filaments Create and Edit pages.

Installation

  1. Require the package via composer:
composer require klisica/filament-builder-blocks
  1. Install it to publish the config file:
php artisan filament-builder-blocks:install
  1. Open the config/filament-builder-blocks.php file and set the path value to root destination where you'll have you PHP classes (or leave it as it is).

  2. Run make section command to create your first example section class with the blade view file:

php artisan make:section Hero

Default folder structure example

Main section Hero.php will be displayed in builder dropdown, while child sections ExampleHero.php and AdvancedHero.php will be displayed as toggle buttons.

├── app
│   ├── Sections
│   │   ├── Header
│   │   │   ├── ExampleHero.php
│   │   │   ├── AdvancedHero.php
│   │   │
│   │   ├── Hero.php

Creating layouts for each section block component.

├── resources
│   ├── views
│   │   ├── sections
│   │   │   ├── example-hero.blade.php
│   │   │   ├── advanced-hero.blade.php

Note

To be sure that on running the cleanup() helper your data won't be remove use the content. prefix on make input methods. This is used a handler to avoid storing inputs that you still need to show for descpritive purposes (i.e. Placeholder component). Take the ExampleHero.php as example:

class ExampleHero extends AbstractSectionItemProvider
{
    public function getFieldset(): Fieldset
    {
        return Fieldset::make($this->getName())
            ->schema([
                Placeholder::make('contact_links')->columnSpanFull(),  // Will get cleared out.
                TextInput::make('content.heading'),    // Will keep on save methods.
            ]);
    }
}

Example for adding cleanup on some Filaments Resource Edit Page:

protected function mutateFormDataBeforeSave(array $data): array
{
    return (new FilamentBuilderBlocks)->cleanup($data);
}

Rendering components

  1. Build sections in controller:
$sections = (new FilamentBuilderBlocks)->renderSections(
    sections: $pages->content,    // Page sections stored in content column
    wrappingSections: $layout->content    // Layout sections stored in content column (includes the `yield` field),
    configs: ['page' => $page, 'layout' => $layout]    // Can be whatever you need to bind in `blade.php` files
);

return view('dynamic')->with('sections', $sections);
  1. Display them in a dynamic.blade.php (or whatever you name it) file:
@foreach($sections as $section)
    {!! $section !!}
@endforeach

Changelog

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

Credits

License

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

统计信息

  • 总下载量: 204
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固