- 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
46 lines
1.8 KiB
PHP
46 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use OpenApi\Attributes as OA;
|
|
|
|
#[OA\Schema(
|
|
schema: 'User',
|
|
properties: [
|
|
new OA\Property(property: 'id', type: 'integer', example: 1),
|
|
new OA\Property(property: 'name', type: 'string', example: 'علی رضایی'),
|
|
new OA\Property(property: 'username', type: 'string', example: 'ali'),
|
|
new OA\Property(property: 'email', type: 'string', format: 'email', example: 'ali@example.com'),
|
|
new OA\Property(property: 'mobile', type: 'string', example: '09123456789'),
|
|
new OA\Property(property: 'avatar_url', type: 'string', example: 'https://example.com/storage/avatars/1.png', nullable: true),
|
|
new OA\Property(property: 'is_public', type: 'boolean', example: false),
|
|
new OA\Property(property: 'social_links', type: 'object', example: ['instagram' => 'https://instagram.com/handle'], nullable: true),
|
|
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
|
|
]
|
|
)]
|
|
/** @mixin User */
|
|
class UserResource extends JsonResource
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'username' => $this->username,
|
|
'email' => $this->email,
|
|
'mobile' => $this->mobile,
|
|
'avatar_url' => $this->avatar_path ? Storage::disk('public')->url($this->avatar_path) : null,
|
|
'is_public' => $this->is_public,
|
|
'social_links' => $this->social_links ?: null,
|
|
'created_at' => $this->created_at?->toIso8601String(),
|
|
];
|
|
}
|
|
}
|