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
43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\Notification;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use OpenApi\Attributes as OA;
|
|
|
|
#[OA\Schema(
|
|
schema: 'Notification',
|
|
properties: [
|
|
new OA\Property(property: 'id', type: 'integer', example: 1),
|
|
new OA\Property(property: 'type', type: 'string', example: 'system'),
|
|
new OA\Property(property: 'type_label', type: 'string', example: 'سیستمی'),
|
|
new OA\Property(property: 'title', type: 'string', example: 'خوش آمدید'),
|
|
new OA\Property(property: 'body', type: 'string', example: 'به هوشپوینت خوش آمدید.'),
|
|
new OA\Property(property: 'data', type: 'object', nullable: true),
|
|
new OA\Property(property: 'read_at', type: 'string', format: 'date-time', nullable: true),
|
|
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
|
|
]
|
|
)]
|
|
/** @mixin Notification */
|
|
class NotificationResource extends JsonResource
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'type' => $this->type->value,
|
|
'type_label' => $this->type->label(),
|
|
'title' => $this->title,
|
|
'body' => $this->body,
|
|
'data' => $this->data,
|
|
'read_at' => $this->read_at?->toIso8601String(),
|
|
'created_at' => $this->created_at?->toIso8601String(),
|
|
];
|
|
}
|
|
}
|