Fills the gaps between the admin panel screens and the backend: a full free-text + slide-count + language -> AI-generated presentation flow with new slide-cloning logic in TemplateFillService, a "my presentations" list endpoint, a swappable payment-gateway structure for wallet top-ups (fake driver for now), and avatar upload / public-profile toggle / account deletion / password change / notification preference endpoints. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
115 lines
4.9 KiB
PHP
115 lines
4.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Templates\RelationManagers;
|
|
|
|
use App\Enums\TemplateKeyType;
|
|
use Filament\Actions\CreateAction;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Schemas\Components\Utilities\Get;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class KeysRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'keys';
|
|
|
|
protected static ?string $title = 'کلیدها';
|
|
|
|
protected static ?string $modelLabel = 'کلید';
|
|
|
|
protected static ?string $pluralModelLabel = 'کلیدها';
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('key')
|
|
->label('کلید')
|
|
->helperText('فقط نام کلید را وارد کنید، بدون آکولاد. مثلاً اگر داخل پاورپوینت نوشتهاید {Main Title}، اینجا فقط Main Title را وارد کنید؛ آکولاد را خود سیستم موقع جایگزینی اضافه میکند. برای عکس/چارت بهجای این، نام شکل (shape name) را در فیلد پایین وارد کنید.')
|
|
->required()
|
|
->maxLength(255),
|
|
TextInput::make('label')
|
|
->label('برچسب')
|
|
->required()
|
|
->maxLength(255),
|
|
Select::make('type')
|
|
->label('نوع')
|
|
->options([
|
|
TemplateKeyType::Text->value => TemplateKeyType::Text->label(),
|
|
TemplateKeyType::Image->value => TemplateKeyType::Image->label(),
|
|
TemplateKeyType::Chart->value => TemplateKeyType::Chart->label(),
|
|
])
|
|
->required()
|
|
->live(),
|
|
TextInput::make('shape_name')
|
|
->label('نام شکل (Shape Name)')
|
|
->helperText('نام شکل تعیینشده در Selection Pane نرمافزار PowerPoint')
|
|
->visible(fn (Get $get): bool => $get('type') !== TemplateKeyType::Text->value)
|
|
->maxLength(255),
|
|
TextInput::make('description')
|
|
->label('راهنما')
|
|
->helperText('توضیحی که برای مصرفکننده API نمایش داده میشود')
|
|
->maxLength(255),
|
|
Toggle::make('is_required')
|
|
->label('اجباری')
|
|
->default(true),
|
|
Toggle::make('is_repeatable')
|
|
->label('تکرارشونده (برای ساخت با هوش مصنوعی)')
|
|
->helperText('اگر فعال باشد، این کلید در اسلاید تکرارشونده قرار دارد و برای هر اسلاید تولیدشده با هوش مصنوعی مقدار جداگانه دریافت میکند.')
|
|
->default(false)
|
|
->visible(fn (Get $get): bool => $get('type') === TemplateKeyType::Text->value),
|
|
TextInput::make('sort_order')
|
|
->label('ترتیب نمایش')
|
|
->numeric()
|
|
->integer()
|
|
->default(0),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('key')
|
|
->columns([
|
|
TextColumn::make('key')
|
|
->label('کلید')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('label')
|
|
->label('برچسب')
|
|
->searchable(),
|
|
TextColumn::make('type')
|
|
->label('نوع')
|
|
->badge()
|
|
->formatStateUsing(fn (TemplateKeyType $state): string => $state->label()),
|
|
TextColumn::make('shape_name')
|
|
->label('نام شکل')
|
|
->placeholder('—'),
|
|
IconColumn::make('is_required')
|
|
->label('اجباری')
|
|
->boolean(),
|
|
IconColumn::make('is_repeatable')
|
|
->label('تکرارشونده')
|
|
->boolean(),
|
|
TextColumn::make('sort_order')
|
|
->label('ترتیب')
|
|
->sortable(),
|
|
])
|
|
->defaultSort('sort_order')
|
|
->headerActions([
|
|
CreateAction::make(),
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
DeleteAction::make(),
|
|
]);
|
|
}
|
|
}
|