feat: add ApiResponse trait for standardized API responses
chore: update composer dependencies to include phppresentation chore: update composer.lock after adding phppresentation feat: create categories migration for category management feat: create templates migration for template storage feat: create template generations migration for tracking template usage feat: create template keys migration for template customization feat: create notifications migration for user notifications feat: update API routes for categories, templates, and user profile management docs: update API documentation to include new endpoints for profile and wallet
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Templates\RelationManagers;
|
||||
|
||||
use App\Enums\TemplateGenerationStatus;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class GenerationsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'generations';
|
||||
|
||||
protected static ?string $title = 'تولیدها';
|
||||
|
||||
protected static ?string $modelLabel = 'تولید';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'تولیدها';
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('uuid')
|
||||
->columns([
|
||||
TextColumn::make('uuid')
|
||||
->label('شناسه')
|
||||
->searchable()
|
||||
->copyable(),
|
||||
TextColumn::make('status')
|
||||
->label('وضعیت')
|
||||
->badge()
|
||||
->formatStateUsing(fn (TemplateGenerationStatus $state): string => $state->label())
|
||||
->color(fn (TemplateGenerationStatus $state): string => match ($state) {
|
||||
TemplateGenerationStatus::Pending => 'gray',
|
||||
TemplateGenerationStatus::Processing => 'warning',
|
||||
TemplateGenerationStatus::Completed => 'success',
|
||||
TemplateGenerationStatus::Failed => 'danger',
|
||||
}),
|
||||
TextColumn::make('requester.name')
|
||||
->label('درخواستدهنده')
|
||||
->placeholder('—'),
|
||||
TextColumn::make('error_message')
|
||||
->label('خطا')
|
||||
->limit(40)
|
||||
->placeholder('—'),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->label('وضعیت')
|
||||
->options([
|
||||
TemplateGenerationStatus::Pending->value => TemplateGenerationStatus::Pending->label(),
|
||||
TemplateGenerationStatus::Processing->value => TemplateGenerationStatus::Processing->label(),
|
||||
TemplateGenerationStatus::Completed->value => TemplateGenerationStatus::Completed->label(),
|
||||
TemplateGenerationStatus::Failed->value => TemplateGenerationStatus::Failed->label(),
|
||||
]),
|
||||
])
|
||||
->recordActions([])
|
||||
->toolbarActions([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?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('در فایل پاورپوینت برای متن بهصورت {{key}} و برای عکس/چارت بهصورت نام شکل (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),
|
||||
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(),
|
||||
TextColumn::make('sort_order')
|
||||
->label('ترتیب')
|
||||
->sortable(),
|
||||
])
|
||||
->defaultSort('sort_order')
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user