52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
/**
|
|
* 활동 로그 컬렉션 리소스
|
|
*
|
|
* 활동 로그 목록을 페이지네이션과 함께 반환합니다.
|
|
*/
|
|
class ActivityLogCollection extends BaseApiCollection
|
|
{
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
protected function abilityMap(): array
|
|
{
|
|
return [
|
|
'can_delete' => 'core.activities.delete',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 활동 로그 컬렉션을 배열로 변환합니다.
|
|
*
|
|
* @param Request $request HTTP 요청 객체
|
|
* @return array<int|string, mixed> 변환된 컬렉션 배열
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
$abilities = $this->resolveCollectionAbilities($request);
|
|
|
|
return [
|
|
'data' => $this->mapWithRowNumber(function ($activityLog) {
|
|
return (new ActivityLogResource($activityLog))->toArray(request());
|
|
}),
|
|
'pagination' => $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(),
|
|
] : null,
|
|
...($abilities ? ['abilities' => $abilities] : []),
|
|
];
|
|
}
|
|
}
|