Files
Gnuboard7/modules/_bundled/sirsoft-ecommerce/src/Http/Resources/CouponIssueCollection.php
T
2026-04-01 10:30:52 +09:00

48 lines
1.3 KiB
PHP

<?php
namespace Modules\Sirsoft\Ecommerce\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Pagination\LengthAwarePaginator;
/**
* 쿠폰 발급 내역 컬렉션 리소스
*/
class CouponIssueCollection extends ResourceCollection
{
/**
* The resource that this resource collects.
*
* @var string
*/
public $collects = CouponIssueResource::class;
/**
* 쿠폰 발급 내역 컬렉션을 배열로 변환합니다.
*
* @param Request $request HTTP 요청 객체
* @return array<string, mixed> 변환된 발급 내역 컬렉션 배열
*/
public function toArray(Request $request): array
{
$result = [
'data' => $this->collection,
];
if ($this->resource instanceof LengthAwarePaginator) {
$result['pagination'] = [
'current_page' => $this->resource->currentPage(),
'last_page' => $this->resource->lastPage(),
'per_page' => $this->resource->perPage(),
'total' => $this->resource->total(),
'from' => $this->resource->firstItem(),
'to' => $this->resource->lastItem(),
'has_more_pages' => $this->resource->hasMorePages(),
];
}
return $result;
}
}