first commit
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Components\Forms;
|
||||
|
||||
use App\Enums\CustomFormStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Filament\Components\Forms\ItemForm\CustomForm\FormBuilderItem;
|
||||
use App\Filament\Components\Forms\ItemForm\Pages\ContentBuilderItem;
|
||||
use App\Helpers\ByteConverter;
|
||||
use App\Models\Category;
|
||||
use App\Models\CustomForm;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Components\Tab;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
class CustomFormForm
|
||||
{
|
||||
|
||||
public static function getForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make()
|
||||
->schema([
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tabs\Tab::make('Основная информация')
|
||||
->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('title')->label('Заголовок')->required()
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string|null $state, Forms\Set $set) {
|
||||
$set('form_id', Str::slug($state));
|
||||
}),
|
||||
TextInput::make('form_id')->label('ID формы')->unique(ignoreRecord: true)->required(),
|
||||
]),
|
||||
Forms\Components\Textarea::make('description')->label('Описание формы')->required(),
|
||||
Select::make('status')->label('Статус формы')->required()
|
||||
->options(CustomFormStatus::class)
|
||||
]),
|
||||
Tabs\Tab::make('Колонки')
|
||||
->schema([
|
||||
FormBuilderItem::getItem(),
|
||||
]),
|
||||
Tabs\Tab::make('Кнопка отправки')
|
||||
->schema([
|
||||
TextInput::make('button')->label('Текст кнопки отправки')->required(),
|
||||
Forms\Components\Textarea::make('send_message')->label('Текст после отправления письма')->required(),
|
||||
]),
|
||||
Tabs\Tab::make('Настройка интеграции с почтой')
|
||||
->schema([
|
||||
Forms\Components\Repeater::make('mail_settings')
|
||||
->label('')
|
||||
->addActionLabel('Добавить получателя')
|
||||
->schema([
|
||||
TextInput::make('target')->label('Кому')->email()->required(),
|
||||
TextInput::make('topic')->label('Тема')->required(),
|
||||
Builder::make('data')->schema([
|
||||
Builder\Block::make('text')->schema([
|
||||
RichEditor::make('content')->required(),
|
||||
]),
|
||||
Builder\Block::make('answers')->schema([]),
|
||||
])->required(),
|
||||
])->collapsed(),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Components\Forms\ItemForm\CustomForm;
|
||||
|
||||
use App\Enums\CustomFormStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Filament\Components\Forms\ItemForm\CustomForm\components\rules\RuleLengthLimitComponent;
|
||||
use App\Filament\Components\Forms\ItemForm\CustomForm\components\rules\RuleRequiredComponent;
|
||||
use App\Filament\Components\Forms\ItemForm\CustomForm\components\rules\RuleUniqueComponent;
|
||||
use App\Helpers\ByteConverter;
|
||||
use App\Models\Category;
|
||||
use App\Models\CustomForm;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
|
||||
class FormBuilderItem
|
||||
{
|
||||
public static function getItem()
|
||||
{
|
||||
return Builder::make('columns')
|
||||
->schema([
|
||||
Builder\Block::make('email')
|
||||
->label('Почта')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
|
||||
Section::make('Настройка')
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
RuleUniqueComponent::getComponent(),
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('phone')
|
||||
->label('Телефон')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
Section::make('Настройка')
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
RuleUniqueComponent::getComponent(),
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('text')
|
||||
->label('Короткий текст')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
|
||||
Section::make('Настройка')
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('textarea')
|
||||
->label('Длинный текст текст')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
Section::make('Настройка')
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('date')
|
||||
->label('Дата')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
Section::make('Настройка')
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
]),
|
||||
|
||||
]),
|
||||
Builder\Block::make('url')
|
||||
->label('Ссылка')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
Section::make('Настройка')
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
RuleUniqueComponent::getComponent(),
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('multiple_choice')
|
||||
->label('Несколько вариантов')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(), Forms\Components\Repeater::make('columns')->schema([
|
||||
TextInput::make('title_field')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
])->collapsed(),
|
||||
|
||||
Section::make('Настройка')
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('single_choice')
|
||||
->label('Один вариант')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(), Forms\Components\Repeater::make('columns')->schema([
|
||||
TextInput::make('title_field')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
])->collapsed(),
|
||||
|
||||
Section::make('Настройка')
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
->label('')
|
||||
->addActionLabel('Добавить поле')
|
||||
->collapsed();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Components\Forms\ItemForm\CustomForm\components\rules;
|
||||
|
||||
use App\Enums\CustomFormStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Helpers\ByteConverter;
|
||||
use App\Models\Category;
|
||||
use App\Models\CustomForm;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
|
||||
class RuleLengthLimitComponent
|
||||
{
|
||||
public static function getComponent() : Section
|
||||
{
|
||||
return Section::make('Ограничить количество символов в ответе')
|
||||
->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
Forms\Components\TextInput::make('min')->label('От')->integer(),
|
||||
Forms\Components\TextInput::make('max')->label('До')->integer()
|
||||
]),
|
||||
Forms\Components\Toggle::make('show_length')->label('Показывать максимальное количество символов под колонкой'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Components\Forms\ItemForm\CustomForm\components\rules;
|
||||
|
||||
use App\Enums\CustomFormStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Helpers\ByteConverter;
|
||||
use App\Models\Category;
|
||||
use App\Models\CustomForm;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
|
||||
class RuleRequiredComponent
|
||||
{
|
||||
public static function getComponent() : Toggle
|
||||
{
|
||||
return Toggle::make('required')->label('Обязательное поле');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Components\Forms\ItemForm\CustomForm\components\rules;
|
||||
|
||||
use App\Enums\CustomFormStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Helpers\ByteConverter;
|
||||
use App\Models\Category;
|
||||
use App\Models\CustomForm;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
|
||||
class RuleUniqueComponent
|
||||
{
|
||||
public static function getComponent() : Toggle
|
||||
{
|
||||
return Toggle::make('unique')->label('Уникальное поле');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Components\Forms\ItemForm\Pages;
|
||||
|
||||
use App\Enums\CustomFormStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Helpers\ByteConverter;
|
||||
use App\Models\Category;
|
||||
use App\Models\CustomForm;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
|
||||
class ContentBuilderItem
|
||||
{
|
||||
public static function getItem()
|
||||
{
|
||||
return
|
||||
Builder::make('content')->label('')->blocks([
|
||||
Builder\Block::make('heading')->label('Заголовок')
|
||||
->schema([
|
||||
TextInput::make('id')->hidden()->integer()->default(rand(2335235,324634264263426)),
|
||||
TextInput::make('content')
|
||||
->label('')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set, $get) {
|
||||
}),
|
||||
]),
|
||||
Builder\Block::make('paragraph')
|
||||
->schema([
|
||||
RichEditor::make('content')
|
||||
->toolbarButtons([
|
||||
'blockquote',
|
||||
'bold',
|
||||
'bulletList',
|
||||
'italic',
|
||||
'link',
|
||||
'orderedList',
|
||||
'redo',
|
||||
'strike',
|
||||
'underline',
|
||||
'undo',
|
||||
])
|
||||
->label(''),
|
||||
])->label('Текст'),
|
||||
Builder\Block::make('files')
|
||||
->schema([
|
||||
Forms\Components\Repeater::make('file')->schema([
|
||||
Hidden::make('expansion')->required(),
|
||||
Hidden::make('size')->required(),
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autofocus(),
|
||||
FileUpload::make('path')
|
||||
->required()
|
||||
->getUploadedFileNameForStorageUsing(
|
||||
fn (TemporaryUploadedFile $file): string =>
|
||||
str(Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '-' . Carbon::now()->timestamp ) . '.' . $file->getClientOriginalExtension())
|
||||
)
|
||||
->acceptedFileTypes([
|
||||
'application/pdf',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'application/zip'
|
||||
])
|
||||
->maxSize(512000)
|
||||
->disk('public')
|
||||
->directory('files')
|
||||
->downloadable()
|
||||
->afterStateUpdated(function ($set, $state) {
|
||||
$set('expansion', $state?->getClientOriginalExtension());
|
||||
$set('size', ByteConverter::bytesToHuman($state?->getSize()));
|
||||
})
|
||||
->visibility('public')
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('person')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Имя')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
FileUpload::make('photo')
|
||||
->label('Фотография')
|
||||
->image()
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor(),
|
||||
Forms\Components\Repeater::make('info')->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('column')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('content')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]),
|
||||
])->minItems(1),
|
||||
]),
|
||||
Builder\Block::make('stepper')
|
||||
->schema([
|
||||
TextInput::make('step_name')
|
||||
->label('Название шага')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\Repeater::make('steps')->schema([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)->columnSpanFull(),
|
||||
RichEditor::make('content')->required(),
|
||||
])->minItems(1),
|
||||
]),
|
||||
Builder\Block::make('tabs')
|
||||
->schema([
|
||||
Forms\Components\Repeater::make('tab')->schema([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)->columnSpanFull(),
|
||||
\Filament\Forms\Components\Builder::make('content')->label('')->blocks([
|
||||
Builder\Block::make('heading')->label('Заголовок')
|
||||
->schema([
|
||||
TextInput::make('id')->hidden()->integer()->default(rand(2335235,324634264263426)),
|
||||
TextInput::make('content')
|
||||
->label('')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set, $get) {
|
||||
}),
|
||||
]),
|
||||
Builder\Block::make('paragraph')
|
||||
->schema([
|
||||
RichEditor::make('content')
|
||||
->toolbarButtons([
|
||||
'blockquote',
|
||||
'bold',
|
||||
'bulletList',
|
||||
'italic',
|
||||
'link',
|
||||
'orderedList',
|
||||
'redo',
|
||||
'strike',
|
||||
'underline',
|
||||
'undo',
|
||||
])
|
||||
->label(''),
|
||||
])->label('Текст'),
|
||||
Builder\Block::make('files')
|
||||
->schema([
|
||||
Forms\Components\Repeater::make('file')->schema([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autofocus(),
|
||||
FileUpload::make('path')
|
||||
->required()
|
||||
->acceptedFileTypes([
|
||||
'application/pdf',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'application/zip'
|
||||
])
|
||||
->maxSize(512000)
|
||||
->disk('public')
|
||||
->directory('files')
|
||||
->downloadable()
|
||||
->visibility('public')
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('person')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Имя')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
FileUpload::make('photo')
|
||||
->label('Фотография')
|
||||
->image()
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor(),
|
||||
Forms\Components\Repeater::make('info')->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('column')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('content')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]),
|
||||
])->minItems(1),
|
||||
]),
|
||||
Builder\Block::make('stepper')
|
||||
->schema([
|
||||
TextInput::make('step_name')
|
||||
->label('Название шага')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\Repeater::make('steps')->schema([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)->columnSpanFull(),
|
||||
RichEditor::make('content')->required(),
|
||||
])->minItems(1),
|
||||
]),
|
||||
Builder\Block::make('images')
|
||||
->schema([
|
||||
FileUpload::make('url')
|
||||
->label('Изображение(-я)')
|
||||
->image()
|
||||
->multiple()
|
||||
->reorderable()
|
||||
->maxFiles(5)
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor()
|
||||
->required(),
|
||||
TextInput::make('alt')
|
||||
->label('Описание')
|
||||
->placeholder('Необязяательно')
|
||||
])->label('Слайдер изображений'),
|
||||
Builder\Block::make('image')
|
||||
->schema([
|
||||
FileUpload::make('url')
|
||||
->label('Изображение(-я)')
|
||||
->image()
|
||||
->multiple()
|
||||
->reorderable()
|
||||
->maxFiles(5)
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor()
|
||||
->required(),
|
||||
TextInput::make('alt')
|
||||
->label('Описание')
|
||||
->placeholder('Необязяательно')
|
||||
])->label('Изображение'),
|
||||
Builder\Block::make('video')
|
||||
->schema([
|
||||
TextInput::make('mime')->readOnly(),
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autofocus(),
|
||||
FileUpload::make('path')
|
||||
->required()
|
||||
->acceptedFileTypes([
|
||||
'video/mp4',
|
||||
'video/quicktime',
|
||||
'video/x-msvideo',
|
||||
'video/x-ms-wmv',
|
||||
'video/avi',
|
||||
'video/webm',
|
||||
'video/ogg',
|
||||
'video/3gpp',
|
||||
'video/3gpp2',
|
||||
'video/x-m4v',
|
||||
])
|
||||
->disk('public')
|
||||
->directory('videos')
|
||||
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
|
||||
]),
|
||||
Builder\Block::make('postsList')
|
||||
->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('count')
|
||||
->label('Количество запией')
|
||||
->integer(),
|
||||
Select::make('category')
|
||||
->options(Category::all()->pluck('title', 'id'))
|
||||
]),
|
||||
])->label('Список новостей'),
|
||||
])
|
||||
->collapsed()
|
||||
->blockNumbers(false)
|
||||
->collapsible()
|
||||
->addActionLabel('Добавить новый блок'),
|
||||
])->minItems(1),
|
||||
]),
|
||||
Builder\Block::make('images')
|
||||
->schema([
|
||||
FileUpload::make('url')
|
||||
->label('Изображение(-я)')
|
||||
->image()
|
||||
->multiple()
|
||||
->reorderable()
|
||||
->maxFiles(5)
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor()
|
||||
->required(),
|
||||
TextInput::make('alt')
|
||||
->label('Описание')
|
||||
->placeholder('Необязяательно')
|
||||
])->label('Слайдер изображений'),
|
||||
Builder\Block::make('image')
|
||||
->schema([
|
||||
FileUpload::make('url')
|
||||
->label('Изображение(-я)')
|
||||
->image()
|
||||
->multiple()
|
||||
->reorderable()
|
||||
->maxFiles(5)
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor()
|
||||
->required(),
|
||||
TextInput::make('alt')
|
||||
->label('Описание')
|
||||
->placeholder('Необязяательно')
|
||||
])->label('Изображение'),
|
||||
Builder\Block::make('video')
|
||||
->schema([
|
||||
TextInput::make('mime')->readOnly(),
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autofocus(),
|
||||
FileUpload::make('path')
|
||||
->required()
|
||||
->acceptedFileTypes([
|
||||
'video/mp4',
|
||||
'video/quicktime',
|
||||
'video/x-msvideo',
|
||||
'video/x-ms-wmv',
|
||||
'video/avi',
|
||||
'video/webm',
|
||||
'video/ogg',
|
||||
'video/3gpp',
|
||||
'video/3gpp2',
|
||||
'video/x-m4v',
|
||||
])
|
||||
->disk('public')
|
||||
->directory('videos')
|
||||
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
|
||||
]),
|
||||
Builder\Block::make('postsList')
|
||||
->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('count')
|
||||
->label('Количество запией')
|
||||
->integer(),
|
||||
Select::make('category')
|
||||
->options(Category::all()->pluck('title', 'id'))
|
||||
]),
|
||||
])->label('Список новостей'),
|
||||
Builder\Block::make('postItem')
|
||||
->schema([
|
||||
Select::make('post')
|
||||
->options(Post::query()->where('status', PostStatus::PUBLISHED)->pluck('title', 'id'))
|
||||
->searchable()
|
||||
->required(),
|
||||
])->label('Новость'),
|
||||
Builder\Block::make('pageItem')
|
||||
->schema([
|
||||
Select::make('page')
|
||||
->options(Page::query()->where('title', '!=' , null)->where('is_visible', true)->pluck('title', 'id'))
|
||||
->searchable()
|
||||
->required(),
|
||||
])->label('Страница'),
|
||||
Builder\Block::make('customForm')
|
||||
->schema([
|
||||
Select::make('form')
|
||||
->options(CustomForm::query()->where('status', CustomFormStatus::PUBLISHED)->pluck('title', 'form_id'))
|
||||
->searchable()
|
||||
->required(),
|
||||
])->label('Форма'),
|
||||
])
|
||||
->collapsed()
|
||||
->blockNumbers(false)
|
||||
->collapsible()
|
||||
->blockPickerColumns(3)
|
||||
->blockPickerWidth('2xl')
|
||||
->addActionLabel('Добавить новый блок');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Components\Forms;
|
||||
|
||||
use App\Enums\CustomFormStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Filament\Components\Forms\ItemForm\Pages\ContentBuilderItem;
|
||||
use App\Helpers\ByteConverter;
|
||||
use App\Models\Category;
|
||||
use App\Models\CustomForm;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Components\Tab;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
class PageForm
|
||||
{
|
||||
|
||||
public static function getPageTemplates() {
|
||||
|
||||
$finder = new Finder();
|
||||
$finder->files()->in('../resources/js/Pages/Client/BasePageTemplate');
|
||||
|
||||
|
||||
$fileInfos = [];
|
||||
foreach ($finder as $fileInfo) {
|
||||
$fileInfos[] = [
|
||||
'filename' => $fileInfo->getBasename('.' . $fileInfo->getExtension()),
|
||||
|
||||
'path' => preg_replace('/.*\/(Client\/.*)/', '$1', $fileInfo->getPath() . '/' . $fileInfo->getBasename('.' . $fileInfo->getExtension())),
|
||||
'extension' => $fileInfo->getExtension(),
|
||||
'size' => $fileInfo->getSize(),
|
||||
'mtime' => $fileInfo->getMTime(),
|
||||
'atime' => $fileInfo->getATime(),
|
||||
'isReadable' => $fileInfo->isReadable(),
|
||||
'isWritable' => $fileInfo->isWritable(),
|
||||
];
|
||||
}
|
||||
$fileInfos = collect($fileInfos);
|
||||
return $fileInfos->pluck('filename', 'path');
|
||||
|
||||
}
|
||||
|
||||
public static function getForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make()
|
||||
->schema([
|
||||
Forms\Components\Tabs::make('')->schema([
|
||||
Forms\Components\Tabs\Tab::make('Основная информация')->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('title')->label('Заголовок')->required()
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('slug', Str::slug($state));
|
||||
$set('path', Str::slug($state));
|
||||
}),
|
||||
TextInput::make('slug')->label('Slug')->unique(ignoreRecord: true)->required()
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set, $get) {
|
||||
$set('path', Str::slug($state));
|
||||
}),
|
||||
]),
|
||||
Select::make('sub_section_id')->label('Подраздел')
|
||||
->relationship('section', 'title')
|
||||
->createOptionForm([
|
||||
Forms\Components\TextInput::make('title')->label('Название подраздела')->required()
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('slug', Str::slug($state));
|
||||
}),
|
||||
TextInput::make('slug')->label('Slug')->unique(ignoreRecord: true)->readOnly()->required(),
|
||||
]),
|
||||
Select::make('code')->options([
|
||||
'200' => 'Открытая страница',
|
||||
'404' => 'Не найдено',
|
||||
'500' => 'Ведутся технические работы',
|
||||
])->label('Статус')->required()->default('200'),
|
||||
Toggle::make('searchable')->default(true)->label('Индексируется поиском')->inline(false),
|
||||
TextInput::make('search_data')->hidden(),
|
||||
]),
|
||||
Forms\Components\Tabs\Tab::make('Контент')->schema([
|
||||
ContentBuilderItem::getItem()
|
||||
]),
|
||||
Forms\Components\Tabs\Tab::make('Настройки')->schema([
|
||||
Select::make('template')->options(self::getPageTemplates())->required(),
|
||||
]),
|
||||
]),
|
||||
|
||||
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Components\Forms;
|
||||
|
||||
use App\Enums\CustomFormStatus;
|
||||
use App\Enums\PostStatus;
|
||||
use App\Filament\Components\Forms\ItemForm\Pages\ContentBuilderItem;
|
||||
use App\Helpers\ByteConverter;
|
||||
use App\Models\Category;
|
||||
use App\Models\CustomForm;
|
||||
use App\Models\Page;
|
||||
use App\Models\Post;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\SpatieTagsInput;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Components\Tab;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
class PostForm
|
||||
{
|
||||
public static function getForm(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Section::make()
|
||||
->schema([
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tabs\Tab::make('Основная информация')
|
||||
->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('title')->label('Заголовок')->required()
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string|null $state, Forms\Set $set) {
|
||||
$set('slug', Str::slug($state));
|
||||
}),
|
||||
TextInput::make('slug')->label('Slug')->unique(ignoreRecord: true)->readOnly()->required(),
|
||||
]),
|
||||
Select::make('status')->options([
|
||||
'verification' => 'На рассмотрении',
|
||||
'published' => 'Одобрено',
|
||||
'rejected' => 'Отказано',
|
||||
])->label('Статус')->required()->default(PostStatus::VERIFICATION),
|
||||
Select::make('category_id')
|
||||
->options(Category::all()->pluck('title', 'id'))
|
||||
->preload()
|
||||
->label('Категория'),
|
||||
SpatieTagsInput::make('tags')->label('Тэги'),
|
||||
Forms\Components\TagsInput::make('authors')
|
||||
->label('Авторы')->placeholder('Добавить автора'),
|
||||
]),
|
||||
Tabs\Tab::make('Содержание новости')
|
||||
->schema([
|
||||
\Filament\Forms\Components\Builder::make('content')->label('')->blocks([
|
||||
Builder\Block::make('heading')->label('Заголовок')
|
||||
->schema([
|
||||
TextInput::make('id')->hidden()->integer()->default(rand(2335235,324634264263426)),
|
||||
TextInput::make('content')
|
||||
->label('')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set, $get) {
|
||||
}),
|
||||
]),
|
||||
Builder\Block::make('paragraph')->label('Текст')
|
||||
->schema([
|
||||
RichEditor::make('content')
|
||||
->toolbarButtons([
|
||||
'blockquote',
|
||||
'bold',
|
||||
'bulletList',
|
||||
'italic',
|
||||
'link',
|
||||
'orderedList',
|
||||
'redo',
|
||||
'strike',
|
||||
'underline',
|
||||
'undo',
|
||||
])
|
||||
->label(''),
|
||||
]),
|
||||
Builder\Block::make('files')->label('Файлы')
|
||||
->schema([
|
||||
Forms\Components\Repeater::make('file')->schema([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autofocus(),
|
||||
FileUpload::make('path')
|
||||
->required()
|
||||
->acceptedFileTypes([
|
||||
'application/pdf',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'application/zip'
|
||||
])
|
||||
->maxSize(512000)
|
||||
->disk('public')
|
||||
->directory('files')
|
||||
->downloadable()
|
||||
->visibility('public')
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('person')->label('Персона')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Имя')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
FileUpload::make('photo')
|
||||
->label('Фотография')
|
||||
->image()
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor(),
|
||||
Forms\Components\Repeater::make('info')->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('column')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('content')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]),
|
||||
])->minItems(1),
|
||||
]),
|
||||
Builder\Block::make('stepper')->label('Этапы')
|
||||
->schema([
|
||||
TextInput::make('step_name')
|
||||
->label('Название шага')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\Repeater::make('steps')->schema([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->live()
|
||||
->maxLength(255)->columnSpanFull(),
|
||||
RichEditor::make('content')->required(),
|
||||
])
|
||||
->itemLabel(fn (array $state): ?string => $state['title'] ?? null)
|
||||
->minItems(1)
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
|
||||
|
||||
]),
|
||||
Builder\Block::make('tabs')->label('Вкладки')
|
||||
->schema([
|
||||
Forms\Components\Repeater::make('tab')->schema([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)->columnSpanFull(),
|
||||
\Filament\Forms\Components\Builder::make('content')->label('')->blocks([
|
||||
Builder\Block::make('heading')->label('Заголовок')
|
||||
->schema([
|
||||
TextInput::make('id')->hidden()->integer()->default(rand(2335235,324634264263426)),
|
||||
TextInput::make('content')
|
||||
->label('')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set, $get) {
|
||||
}),
|
||||
]),
|
||||
Builder\Block::make('paragraph')
|
||||
->schema([
|
||||
RichEditor::make('content')
|
||||
->toolbarButtons([
|
||||
'blockquote',
|
||||
'bold',
|
||||
'bulletList',
|
||||
'italic',
|
||||
'link',
|
||||
'orderedList',
|
||||
'redo',
|
||||
'strike',
|
||||
'underline',
|
||||
'undo',
|
||||
])
|
||||
->label(''),
|
||||
])->label('Текст'),
|
||||
Builder\Block::make('files')
|
||||
->schema([
|
||||
Forms\Components\Repeater::make('file')->schema([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autofocus(),
|
||||
FileUpload::make('path')
|
||||
->required()
|
||||
->acceptedFileTypes([
|
||||
'application/pdf',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'application/zip'
|
||||
])
|
||||
->maxSize(512000)
|
||||
->disk('public')
|
||||
->directory('files')
|
||||
->downloadable()
|
||||
->visibility('public')
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('person')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Имя')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
FileUpload::make('photo')
|
||||
->label('Фотография')
|
||||
->image()
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor(),
|
||||
Forms\Components\Repeater::make('info')->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('column')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('content')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]),
|
||||
])->minItems(1),
|
||||
]),
|
||||
Builder\Block::make('stepper')
|
||||
->schema([
|
||||
TextInput::make('step_name')
|
||||
->label('Название шага')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\Repeater::make('steps')->schema([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)->columnSpanFull(),
|
||||
RichEditor::make('content')->required(),
|
||||
])->minItems(1),
|
||||
]),
|
||||
Builder\Block::make('images')
|
||||
->schema([
|
||||
FileUpload::make('url')
|
||||
->label('Изображение(-я)')
|
||||
->image()
|
||||
->multiple()
|
||||
->reorderable()
|
||||
->maxFiles(5)
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor()
|
||||
->required(),
|
||||
TextInput::make('alt')
|
||||
->label('Описание')
|
||||
->placeholder('Необязяательно')
|
||||
])->label('Слайдер изображений'),
|
||||
Builder\Block::make('image')
|
||||
->schema([
|
||||
FileUpload::make('url')
|
||||
->label('Изображение(-я)')
|
||||
->image()
|
||||
->multiple()
|
||||
->reorderable()
|
||||
->maxFiles(5)
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor()
|
||||
->required(),
|
||||
TextInput::make('alt')
|
||||
->label('Описание')
|
||||
->placeholder('Необязяательно')
|
||||
])->label('Изображение'),
|
||||
Builder\Block::make('video')
|
||||
->schema([
|
||||
TextInput::make('mime')->readOnly(),
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autofocus(),
|
||||
FileUpload::make('path')
|
||||
->required()
|
||||
->acceptedFileTypes([
|
||||
'video/mp4',
|
||||
'video/quicktime',
|
||||
'video/x-msvideo',
|
||||
'video/x-ms-wmv',
|
||||
'video/avi',
|
||||
'video/webm',
|
||||
'video/ogg',
|
||||
'video/3gpp',
|
||||
'video/3gpp2',
|
||||
'video/x-m4v',
|
||||
])
|
||||
->disk('public')
|
||||
->directory('videos')
|
||||
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
|
||||
]),
|
||||
Builder\Block::make('postsList')
|
||||
->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('count')
|
||||
->label('Количество запией')
|
||||
->integer(),
|
||||
Select::make('category')
|
||||
->options(Category::all()->pluck('title', 'id'))
|
||||
]),
|
||||
])->label('Список новостей'),
|
||||
])
|
||||
->collapsed()
|
||||
->blockNumbers(false)
|
||||
->collapsible()
|
||||
->addActionLabel('Добавить новый блок'),
|
||||
])->minItems(1),
|
||||
]),
|
||||
Builder\Block::make('images')->label('Слайдер изображений')
|
||||
->schema([
|
||||
FileUpload::make('url')
|
||||
->label('Изображение(-я)')
|
||||
->image()
|
||||
->multiple()
|
||||
->reorderable()
|
||||
->maxFiles(5)
|
||||
->disk('public')
|
||||
|
||||
->directory('images')
|
||||
->imageEditor()
|
||||
->required(),
|
||||
TextInput::make('alt')
|
||||
->label('Описание')
|
||||
->placeholder('Необязяательно')
|
||||
]),
|
||||
Builder\Block::make('image')->label('Изображение')
|
||||
->schema([
|
||||
FileUpload::make('url')
|
||||
->label('Изображение(-я)')
|
||||
->image()
|
||||
->multiple()
|
||||
->reorderable()
|
||||
->maxFiles(5)
|
||||
->disk('public')
|
||||
->directory('images')
|
||||
->imageEditor()
|
||||
->required(),
|
||||
TextInput::make('alt')
|
||||
->label('Описание')
|
||||
->placeholder('Необязяательно')
|
||||
]),
|
||||
Builder\Block::make('video')->label('Видео')
|
||||
->schema([
|
||||
TextInput::make('mime')->readOnly(),
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->autofocus(),
|
||||
FileUpload::make('path')
|
||||
->required()
|
||||
->acceptedFileTypes([
|
||||
'video/mp4',
|
||||
'video/quicktime',
|
||||
'video/x-msvideo',
|
||||
'video/x-ms-wmv',
|
||||
'video/avi',
|
||||
'video/webm',
|
||||
'video/ogg',
|
||||
'video/3gpp',
|
||||
'video/3gpp2',
|
||||
'video/x-m4v',
|
||||
])
|
||||
->disk('public')
|
||||
->directory('videos')
|
||||
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
|
||||
]),
|
||||
Builder\Block::make('postsList')->label('Список новостей')
|
||||
->schema([
|
||||
Forms\Components\Grid::make(2)->schema([
|
||||
TextInput::make('count')
|
||||
->label('Количество запией')
|
||||
->integer(),
|
||||
Select::make('category')
|
||||
->options(Category::all()->pluck('title', 'id'))
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('postItem')->label('Новость')
|
||||
->schema([
|
||||
Select::make('post')
|
||||
->options(Post::query()->where('status', PostStatus::PUBLISHED)->pluck('title', 'id'))
|
||||
->searchable()
|
||||
->required(),
|
||||
]),
|
||||
Builder\Block::make('pageItem')->label('Страница')
|
||||
->schema([
|
||||
Select::make('page')
|
||||
->options(Page::query()->where('title', '!=' , null)->where('is_visible', true)->pluck('title', 'id'))
|
||||
->searchable()
|
||||
->required(),
|
||||
]),
|
||||
])
|
||||
->collapsed()
|
||||
->blockNumbers(false)
|
||||
->collapsible()
|
||||
->blockPickerColumns(3)
|
||||
->blockPickerWidth('2xl')
|
||||
->addActionLabel('Добавить новый блок'),
|
||||
]),
|
||||
Tabs\Tab::make('Изображения')
|
||||
->schema([
|
||||
FileUpload::make('preview')->label('Превью новости')
|
||||
->image()
|
||||
->optimize('webp')
|
||||
->resize(50)
|
||||
->imageEditor()
|
||||
->directory('images'),
|
||||
FileUpload::make('images')->label('Альбом')
|
||||
->image()
|
||||
->optimize('jpg')
|
||||
->resize(30)
|
||||
->imageEditor()
|
||||
->panelLayout('grid')
|
||||
->reorderable()
|
||||
->imageEditor()
|
||||
->multiple()
|
||||
->directory('images'),
|
||||
]),
|
||||
]),
|
||||
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user