31 lines
737 B
PHP
31 lines
737 B
PHP
<?php
|
|
|
|
namespace Modules\Cms\Http\Resources;
|
|
|
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
|
|
class ArticleCollection extends ResourceCollection
|
|
{
|
|
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'data' => $this->collection->map(function ($article) {
|
|
return new ArticleBaseResource($article);
|
|
}),
|
|
'page' => $this->page(),
|
|
];
|
|
}
|
|
|
|
protected function page(): array
|
|
{
|
|
return [
|
|
'current' => $this->currentPage(),
|
|
'total_page' => $this->lastPage(),
|
|
'per_page' => $this->perPage(),
|
|
'has_more' => $this->hasMorePages(),
|
|
'total' => $this->total(),
|
|
];
|
|
}
|
|
|
|
} |