Files
hoshpoint-backend/app/Http/Resources/TemplateGenerationResource.php
soheil khaledabadi 46ae711a20 feat(api): add AI text-to-deck generation, wallet deposit structure, and profile/notification endpoints
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>
2026-08-29 01:36:17 +03:30

62 lines
2.6 KiB
PHP

<?php
namespace App\Http\Resources;
use App\Models\TemplateGeneration;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use OpenApi\Attributes as OA;
#[OA\Schema(
schema: 'TemplateGeneration',
properties: [
new OA\Property(property: 'uuid', type: 'string', example: '9d6f0b1e-9a3a-4f0a-8a1a-6c9a2e5b3d10'),
new OA\Property(property: 'title', type: 'string', example: 'گزارش فروش سال ۱۴۰۴'),
new OA\Property(property: 'source', type: 'string', example: 'ai_text'),
new OA\Property(property: 'source_label', type: 'string', example: 'ساخت با هوش مصنوعی از متن'),
new OA\Property(property: 'language', type: 'string', example: 'fa', nullable: true),
new OA\Property(property: 'slide_count', type: 'integer', example: 10, nullable: true),
new OA\Property(
property: 'template',
properties: [
new OA\Property(property: 'title', type: 'string'),
new OA\Property(property: 'slug', type: 'string'),
],
type: 'object',
nullable: true
),
new OA\Property(property: 'status', type: 'string', example: 'completed'),
new OA\Property(property: 'status_label', type: 'string', example: 'تکمیل شده'),
new OA\Property(property: 'error_message', type: 'string', example: null, nullable: true),
new OA\Property(property: 'download_url', type: 'string', example: 'https://example.com/api/generations/9d6f.../download', nullable: true),
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
]
)]
/** @mixin TemplateGeneration */
class TemplateGenerationResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'uuid' => $this->uuid,
'title' => $this->title ?: $this->template?->title,
'source' => $this->source->value,
'source_label' => $this->source->label(),
'language' => $this->language,
'slide_count' => $this->slide_count,
'template' => $this->template ? [
'title' => $this->template->title,
'slug' => $this->template->slug,
] : null,
'status' => $this->status->value,
'status_label' => $this->status->label(),
'error_message' => $this->error_message,
'download_url' => $this->output_path ? route('api.generations.download', $this->uuid) : null,
'created_at' => $this->created_at?->toIso8601String(),
];
}
}