feat: add ApiResponse trait for standardized API responses
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
This commit is contained in:
42
app/Http/Resources/WalletTransactionResource.php
Normal file
42
app/Http/Resources/WalletTransactionResource.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\WalletTransaction;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
#[OA\Schema(
|
||||
schema: 'WalletTransaction',
|
||||
properties: [
|
||||
new OA\Property(property: 'id', type: 'integer', example: 1),
|
||||
new OA\Property(property: 'type', type: 'string', example: 'credit'),
|
||||
new OA\Property(property: 'type_label', type: 'string', example: 'واریز'),
|
||||
new OA\Property(property: 'amount', type: 'integer', example: 100000),
|
||||
new OA\Property(property: 'balance_before', type: 'integer', example: 400000),
|
||||
new OA\Property(property: 'balance_after', type: 'integer', example: 500000),
|
||||
new OA\Property(property: 'description', type: 'string', example: 'شارژ کیف پول', nullable: true),
|
||||
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
|
||||
]
|
||||
)]
|
||||
/** @mixin WalletTransaction */
|
||||
class WalletTransactionResource 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(),
|
||||
'amount' => $this->amount,
|
||||
'balance_before' => $this->balance_before,
|
||||
'balance_after' => $this->balance_after,
|
||||
'description' => $this->description,
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user