UserCollection.php 489 B

123456789101112131415161718192021
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\ResourceCollection;
  5. class UserCollection extends ResourceCollection
  6. {
  7. /**
  8. * Transform the resource collection into an array.
  9. *
  10. * @return array<int|string, mixed>
  11. */
  12. public function toArray(Request $request): array
  13. {
  14. return $this->collection->transform(function ($user) {
  15. return new UserResource($user);
  16. })->toArray();
  17. }
  18. }