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
45 lines
1.6 KiB
PHP
45 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\Template;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use OpenApi\Attributes as OA;
|
|
|
|
#[OA\Schema(
|
|
schema: 'Template',
|
|
properties: [
|
|
new OA\Property(property: 'id', type: 'integer', example: 1),
|
|
new OA\Property(property: 'title', type: 'string', example: 'گزارش فروش ماهانه'),
|
|
new OA\Property(property: 'slug', type: 'string', example: 'monthly-sales-report'),
|
|
new OA\Property(property: 'description', type: 'string', example: 'قالب گزارش فروش ماهانه', nullable: true),
|
|
new OA\Property(property: 'thumbnail_url', type: 'string', example: 'https://example.com/storage/templates/thumbnails/1.png', nullable: true),
|
|
new OA\Property(property: 'category', ref: '#/components/schemas/Category'),
|
|
new OA\Property(
|
|
property: 'keys',
|
|
type: 'array',
|
|
items: new OA\Items(ref: '#/components/schemas/TemplateKey')
|
|
),
|
|
]
|
|
)]
|
|
/** @mixin Template */
|
|
class TemplateResource extends JsonResource
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'title' => $this->title,
|
|
'slug' => $this->slug,
|
|
'description' => $this->description,
|
|
'thumbnail_url' => $this->thumbnail_path ? asset('storage/'.$this->thumbnail_path) : null,
|
|
'category' => new CategoryResource($this->whenLoaded('category')),
|
|
'keys' => TemplateKeyResource::collection($this->whenLoaded('keys')),
|
|
];
|
|
}
|
|
}
|