- 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
86 lines
2.8 KiB
PHP
86 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Contracts\PaymentGateway;
|
|
use App\Models\Notification;
|
|
use App\Models\Permission;
|
|
use App\Models\Role;
|
|
use App\Models\User;
|
|
use App\Models\Wallet;
|
|
use App\Models\WalletTransaction;
|
|
use App\Observers\UserObserver;
|
|
use App\Policies\NotificationPolicy;
|
|
use App\Policies\PermissionPolicy;
|
|
use App\Policies\RolePolicy;
|
|
use App\Policies\UserPolicy;
|
|
use App\Policies\WalletPolicy;
|
|
use App\Policies\WalletTransactionPolicy;
|
|
use App\Services\Payments\FakePaymentGateway;
|
|
use App\Support\Jalali;
|
|
use Filament\Infolists\Components\TextEntry;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
// Swap this binding for a real gateway (ZarinPal, Zibal, ...) once one is integrated.
|
|
$this->app->bind(PaymentGateway::class, FakePaymentGateway::class);
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
if (app()->environment('production') || str_starts_with((string) config('app.url'), 'https://')) {
|
|
URL::forceScheme('https');
|
|
}
|
|
|
|
$this->registerJalaliMacros();
|
|
|
|
User::observe(UserObserver::class);
|
|
|
|
Gate::policy(User::class, UserPolicy::class);
|
|
Gate::policy(Role::class, RolePolicy::class);
|
|
Gate::policy(Permission::class, PermissionPolicy::class);
|
|
Gate::policy(Wallet::class, WalletPolicy::class);
|
|
Gate::policy(WalletTransaction::class, WalletTransactionPolicy::class);
|
|
Gate::policy(Notification::class, NotificationPolicy::class);
|
|
}
|
|
|
|
/**
|
|
* Adds ->jalaliDate() / ->jalaliDateTime() helpers to Filament table columns and
|
|
* infolist entries so every date shown in the admin panel is Shamsi.
|
|
*/
|
|
private function registerJalaliMacros(): void
|
|
{
|
|
TextColumn::macro('jalaliDate', function () {
|
|
/** @var TextColumn $this */
|
|
return $this->formatStateUsing(fn ($state): ?string => Jalali::date($state));
|
|
});
|
|
|
|
TextColumn::macro('jalaliDateTime', function () {
|
|
/** @var TextColumn $this */
|
|
return $this->formatStateUsing(fn ($state): ?string => Jalali::dateTime($state));
|
|
});
|
|
|
|
TextEntry::macro('jalaliDate', function () {
|
|
/** @var TextEntry $this */
|
|
return $this->formatStateUsing(fn ($state): ?string => Jalali::date($state));
|
|
});
|
|
|
|
TextEntry::macro('jalaliDateTime', function () {
|
|
/** @var TextEntry $this */
|
|
return $this->formatStateUsing(fn ($state): ?string => Jalali::dateTime($state));
|
|
});
|
|
}
|
|
}
|