feat: Persian panel/API fixes and structural-model tweaks
- lang/fa: add validation/auth/passwords/pagination translations so admin and API validation errors are in Persian - templates: soft-delete instead of cascade-deleting their generations; keep resolving trashed template on generations (labels/downloads) - templates: add TemplateInfolist with a real thumbnail ImageEntry - generations: auto-name template-based generations and use that name for the download file and as a searchable column - admin: show all dates as Jalali via ->jalaliDate()/->jalaliDateTime() Filament macros (App\Support\Jalali) - wallets: harden the deposit/withdraw action to surface the exact error instead of a 500 - profile: normalize Iranian mobile numbers (App\Support\Mobile), add social_links, coerce notification-preference booleans, require the current password to delete an account Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013P66ea1dC5CVM9t29496t5
This commit is contained in:
@@ -40,7 +40,7 @@ class AiProvidersTable
|
||||
->boolean(),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ ایجاد')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
|
||||
@@ -32,7 +32,7 @@ class CategoriesTable
|
||||
->boolean(),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ ایجاد')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
|
||||
@@ -37,7 +37,7 @@ class NotificationsTable
|
||||
->getStateUsing(fn ($record): bool => $record->read_at !== null),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ ایجاد')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
|
||||
@@ -28,7 +28,7 @@ class PermissionsTable
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ ایجاد')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
|
||||
@@ -28,7 +28,7 @@ class RolesTable
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ ایجاد')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
|
||||
@@ -13,6 +13,10 @@ class TemplateGenerationInfolist
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('title')
|
||||
->label('نام فایل')
|
||||
->placeholder('—')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('uuid')
|
||||
->label('شناسه')
|
||||
->copyable(),
|
||||
@@ -42,7 +46,7 @@ class TemplateGenerationInfolist
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('created_at')
|
||||
->label('تاریخ ایجاد')
|
||||
->dateTime(),
|
||||
->jalaliDateTime(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,17 @@ class TemplateGenerationsTable
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('title')
|
||||
->label('نام فایل')
|
||||
->searchable()
|
||||
->sortable()
|
||||
->description(fn ($record): string => $record->uuid)
|
||||
->wrap(),
|
||||
TextColumn::make('uuid')
|
||||
->label('شناسه')
|
||||
->searchable()
|
||||
->copyable(),
|
||||
->copyable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('template.title')
|
||||
->label('قالب')
|
||||
->searchable()
|
||||
@@ -44,7 +51,7 @@ class TemplateGenerationsTable
|
||||
->placeholder('—'),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace App\Filament\Resources\Templates\Pages;
|
||||
|
||||
use App\Filament\Resources\Templates\TemplateResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
@@ -16,6 +18,8 @@ class EditTemplate extends EditRecord
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,15 @@ class GenerationsRelationManager extends RelationManager
|
||||
return $table
|
||||
->recordTitleAttribute('uuid')
|
||||
->columns([
|
||||
TextColumn::make('title')
|
||||
->label('نام فایل')
|
||||
->searchable()
|
||||
->wrap(),
|
||||
TextColumn::make('uuid')
|
||||
->label('شناسه')
|
||||
->searchable()
|
||||
->copyable(),
|
||||
->copyable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('status')
|
||||
->label('وضعیت')
|
||||
->badge()
|
||||
@@ -48,7 +53,7 @@ class GenerationsRelationManager extends RelationManager
|
||||
->placeholder('—'),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
|
||||
@@ -46,7 +46,9 @@ class TemplateForm
|
||||
->label('تصویر بندانگشتی')
|
||||
->disk('public')
|
||||
->directory('templates/thumbnails')
|
||||
->image(),
|
||||
->visibility('public')
|
||||
->image()
|
||||
->imageEditor(),
|
||||
Toggle::make('is_active')
|
||||
->label('فعال')
|
||||
->default(true),
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Templates\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
use Filament\Infolists\Components\ImageEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TemplateInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
ImageEntry::make('thumbnail_path')
|
||||
->label('تصویر بندانگشتی')
|
||||
->disk('public')
|
||||
->visibility('public')
|
||||
->height(180)
|
||||
->placeholder('بدون تصویر')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('title')
|
||||
->label('عنوان'),
|
||||
TextEntry::make('slug')
|
||||
->label('شناسه')
|
||||
->copyable(),
|
||||
TextEntry::make('category.name')
|
||||
->label('دستهبندی')
|
||||
->placeholder('—'),
|
||||
TextEntry::make('description')
|
||||
->label('توضیحات')
|
||||
->placeholder('—')
|
||||
->columnSpanFull(),
|
||||
IconEntry::make('is_active')
|
||||
->label('فعال')
|
||||
->boolean(),
|
||||
IconEntry::make('is_ai_enabled')
|
||||
->label('ساخت با هوش مصنوعی')
|
||||
->boolean(),
|
||||
TextEntry::make('ai_repeatable_slide_number')
|
||||
->label('شماره اسلاید تکرارشونده')
|
||||
->placeholder('—'),
|
||||
TextEntry::make('generations_count')
|
||||
->label('تعداد تولیدها')
|
||||
->state(fn ($record): int => $record->generations()->count()),
|
||||
TextEntry::make('creator.name')
|
||||
->label('ایجادکننده')
|
||||
->placeholder('—'),
|
||||
TextEntry::make('created_at')
|
||||
->label('تاریخ ایجاد')
|
||||
->jalaliDateTime(),
|
||||
TextEntry::make('updated_at')
|
||||
->label('آخرین بروزرسانی')
|
||||
->jalaliDateTime(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,19 @@ namespace App\Filament\Resources\Templates\Tables;
|
||||
|
||||
use App\Filament\Resources\Templates\Actions\GenerateWithAiAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TemplatesTable
|
||||
@@ -35,7 +41,7 @@ class TemplatesTable
|
||||
->boolean(),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ ایجاد')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
@@ -48,15 +54,22 @@ class TemplatesTable
|
||||
->placeholder('همه')
|
||||
->trueLabel('فعال')
|
||||
->falseLabel('غیرفعال'),
|
||||
TrashedFilter::make()
|
||||
->label('وضعیت حذف'),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
GenerateWithAiAction::make(),
|
||||
DeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
RestoreBulkAction::make(),
|
||||
ForceDeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Filament\Resources\Templates\Pages\ViewTemplate;
|
||||
use App\Filament\Resources\Templates\RelationManagers\GenerationsRelationManager;
|
||||
use App\Filament\Resources\Templates\RelationManagers\KeysRelationManager;
|
||||
use App\Filament\Resources\Templates\Schemas\TemplateForm;
|
||||
use App\Filament\Resources\Templates\Schemas\TemplateInfolist;
|
||||
use App\Filament\Resources\Templates\Tables\TemplatesTable;
|
||||
use App\Models\Template;
|
||||
use BackedEnum;
|
||||
@@ -16,6 +17,8 @@ use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use UnitEnum;
|
||||
|
||||
class TemplateResource extends Resource
|
||||
@@ -41,11 +44,22 @@ class TemplateResource extends Resource
|
||||
return TemplateForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return TemplateInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TemplatesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([SoftDeletingScope::class]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Users\Schemas;
|
||||
|
||||
use App\Support\Mobile;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -25,6 +26,13 @@ class UserForm
|
||||
TextInput::make('mobile')
|
||||
->label('شماره موبایل')
|
||||
->tel()
|
||||
->helperText('مثال درست: 09123456789')
|
||||
->dehydrateStateUsing(fn (?string $state): ?string => Mobile::normalize($state))
|
||||
->rules([static function (string $attribute, mixed $value, \Closure $fail): void {
|
||||
if (filled($value) && ! preg_match(Mobile::REGEX, (string) Mobile::normalize((string) $value))) {
|
||||
$fail('فرمت شماره موبایل صحیح نیست. مثال درست: 09123456789');
|
||||
}
|
||||
}])
|
||||
->unique(ignoreRecord: true)
|
||||
->maxLength(20),
|
||||
TextInput::make('password')
|
||||
|
||||
@@ -33,7 +33,7 @@ class UsersTable
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ ایجاد')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
|
||||
@@ -46,7 +46,7 @@ class WalletTransactionsTable
|
||||
->placeholder('سیستم'),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
|
||||
@@ -44,7 +44,7 @@ class TransactionsRelationManager extends RelationManager
|
||||
->placeholder('سیستم'),
|
||||
TextColumn::make('created_at')
|
||||
->label('تاریخ')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
|
||||
@@ -15,7 +15,7 @@ use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
|
||||
class WalletsTable
|
||||
{
|
||||
@@ -45,7 +45,7 @@ class WalletsTable
|
||||
->boolean(),
|
||||
TextColumn::make('updated_at')
|
||||
->label('آخرین بروزرسانی')
|
||||
->dateTime()
|
||||
->jalaliDateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
@@ -84,21 +84,27 @@ class WalletsTable
|
||||
->rows(2),
|
||||
])
|
||||
->action(function (Wallet $record, array $data, WalletService $walletService): void {
|
||||
$amount = (int) $data['amount'];
|
||||
$description = filled($data['description'] ?? null) ? $data['description'] : null;
|
||||
|
||||
try {
|
||||
$transaction = $type === 'credit'
|
||||
? $walletService->credit($record, (int) $data['amount'], $data['description'] ?? null, auth()->user())
|
||||
: $walletService->debit($record, (int) $data['amount'], $data['description'] ?? null, auth()->user());
|
||||
? $walletService->credit($record, $amount, $description, auth()->user())
|
||||
: $walletService->debit($record, $amount, $description, auth()->user());
|
||||
|
||||
Notification::make()
|
||||
->title($type === 'credit' ? 'واریز انجام شد' : 'برداشت انجام شد')
|
||||
->body('موجودی جدید: '.number_format($transaction->balance_after).' تومان')
|
||||
->success()
|
||||
->send();
|
||||
} catch (RuntimeException $exception) {
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
|
||||
Notification::make()
|
||||
->title('خطا')
|
||||
->body($exception->getMessage())
|
||||
->title($type === 'credit' ? 'واریز ناموفق بود' : 'برداشت ناموفق بود')
|
||||
->body($exception->getMessage() ?: 'خطای نامشخص هنگام ثبت تراکنش.')
|
||||
->danger()
|
||||
->persistent()
|
||||
->send();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user