Files
Gnuboard7/app/Http/Resources/ScheduleHistoryCollection.php
T
2026-04-20 20:37:49 +09:00

34 lines
1.1 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
class ScheduleHistoryCollection extends BaseApiCollection
{
/**
* 스케줄 실행 이력 컬렉션을 배열로 변환합니다.
*
* @param Request $request HTTP 요청 객체
* @return array<int|string, mixed> 변환된 이력 컬렉션 배열
*/
public function toArray(Request $request): array
{
return [
'data' => $this->collection->map(function ($history) {
return (new ScheduleHistoryResource($history))->toListArray();
}),
'pagination' => $this->when($this->resource instanceof LengthAwarePaginator, [
'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(),
]),
];
}
}