refactor(backend): reorganize domains into Core, Commerce, Ticketing and Shared
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Ticket\Resources\AdminApp;
|
||||
|
||||
use App\Domains\Ticket\Services\AdminAppTicketResult;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
|
||||
class AdminAppTicketCollection extends ResourceCollection
|
||||
{
|
||||
/** @var class-string<AdminAppTicketResource> */
|
||||
public $collects = AdminAppTicketResource::class;
|
||||
|
||||
private readonly int $scannedTickets;
|
||||
|
||||
private readonly int $totalTickets;
|
||||
|
||||
private readonly string $refundedTotal;
|
||||
|
||||
public function __construct(AdminAppTicketResult $result)
|
||||
{
|
||||
parent::__construct($result->tickets);
|
||||
|
||||
$this->scannedTickets = $result->scannedTickets;
|
||||
$this->totalTickets = $result->totalTickets;
|
||||
$this->refundedTotal = $result->refundedTotal;
|
||||
}
|
||||
|
||||
/** @return array{scanned_tickets: int, total_tickets: int, refunded_total: string} */
|
||||
public function with(Request $request): array
|
||||
{
|
||||
return [
|
||||
'scanned_tickets' => $this->scannedTickets,
|
||||
'total_tickets' => $this->totalTickets,
|
||||
'refunded_total' => $this->refundedTotal,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Ticket\Resources\AdminApp;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @property-read array{
|
||||
* total: string|null,
|
||||
* partial: string|null,
|
||||
* } $resource
|
||||
*/
|
||||
class AdminAppTicketRefundCalculationResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array{total: string|null, partial: string|null}
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'total' => $this->resource['total'],
|
||||
'partial' => $this->resource['partial'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Ticket\Resources\AdminApp;
|
||||
|
||||
use App\Domains\Ticket\Models\Ticket;
|
||||
use App\Domains\Ticket\Resources\TicketResource;
|
||||
use App\Domains\Ticket\Services\AdminAppTicketRowService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/** @mixin Ticket */
|
||||
class AdminAppTicketResource extends TicketResource
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$rowService = app(AdminAppTicketRowService::class);
|
||||
$details = $rowService->details($this->resource);
|
||||
|
||||
return [
|
||||
...parent::toArray($request),
|
||||
...$details,
|
||||
'allow_refund' => $this->resource->allow_refund(),
|
||||
'is_active' => $this->resource->is_active(),
|
||||
'can_cancel' => $this->resource->can_cancel(),
|
||||
'can_refund' => $this->resource->can_refund(),
|
||||
'refund' => $this->resource->refund === null ? null : [
|
||||
'type' => $this->resource->refund->type,
|
||||
'type_label' => $this->resource->refund->typeLabel(),
|
||||
'amount' => $this->resource->refund->amount,
|
||||
'created_at' => $this->resource->refund->created_at,
|
||||
'created_by' => $this->resource->refund->createdBy?->nombre_apellido,
|
||||
],
|
||||
'values' => $rowService->values($this->resource, $details),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user