Add Menu Template functionality: Created MenuTemplate resource with CRUD pages, schemas, and table configuration. Implemented localization for menu template fields and integrated menu rendering capabilities. Enhanced TemplatePreviewController to support menu templates and updated dynamic template documentation accordingly.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\MenuTemplates\Schemas;
|
||||
|
||||
use App\Models\MenuTemplate;
|
||||
use Filament\Forms\Components\CodeEditor;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Forms\Components\CodeEditor\Enums\Language;
|
||||
|
||||
class MenuTemplateForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make(__('menu-templates.section_general'))
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
->label(__('menu-templates.field_title'))
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->columnSpanFull(),
|
||||
|
||||
CodeEditor::make('html_content')
|
||||
->label(__('menu-templates.field_html_content'))
|
||||
->required()
|
||||
->live(onBlur: true)
|
||||
->language(Language::Html)
|
||||
->columnSpanFull()
|
||||
->helperText(__('menu-templates.field_html_content_help'))
|
||||
->extraAttributes([
|
||||
'style' => 'max-height: 400px;overflow-y: auto;',
|
||||
'data-field-name' => 'html_content',
|
||||
]),
|
||||
|
||||
// Preview Component
|
||||
View::make('components.menu-template-preview')
|
||||
->viewData(function ($record) {
|
||||
return [
|
||||
'type' => 'menu',
|
||||
'fieldName' => 'html_content',
|
||||
'recordId' => $record?->id,
|
||||
];
|
||||
})
|
||||
->columnSpanFull(),
|
||||
|
||||
Toggle::make('is_active')
|
||||
->label(__('menu-templates.field_is_active'))
|
||||
->default(true)
|
||||
->inline(false),
|
||||
])
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user