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
39 lines
1.4 KiB
PHP
39 lines
1.4 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: '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,
|
|
'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(),
|
|
];
|
|
}
|
|
}
|