32 lines
848 B
PHP
32 lines
848 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Staff;
|
|
|
|
use Illuminate\Http\Resources\Json\ResourceCollection;
|
|
|
|
class StaffCollection extends ResourceCollection
|
|
{
|
|
public function toArray($request): array
|
|
{
|
|
return $this->collection->map(function ($item) use ($request) {
|
|
return (new StaffResource($item))->toArray($request);
|
|
})->all();
|
|
}
|
|
|
|
public function with($request): array
|
|
{
|
|
if (!method_exists($this->resource, 'total')) {
|
|
return [];
|
|
}
|
|
|
|
return [
|
|
'meta' => [
|
|
'total' => $this->resource->total() ?? null,
|
|
'per_page' => $this->resource->perPage() ?? null,
|
|
'current_page' => $this->resource->currentPage() ?? null,
|
|
'last_page' => $this->resource->lastPage() ?? null,
|
|
],
|
|
];
|
|
}
|
|
}
|