app/Http/Resources/UserCollection.php
/**
     * Transform the resource collection into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
Transform the resource collection into an array.
Transform the resource collection into an array .
public function toArray($request)
    {
        return [
            'data' => $this->collection->map(function ($item){
                return [
                  'Name' => $item->name,
                  'Email' => $item->email,
                ];
            })
        ];
    }
public function toArray ( $ request ) { return [ 'data' => $ this -> collection -> map ( function ( $ item ) { return [ 'Name' => $ item -> name , 'Email' => $ item -> email , ] ; } ) ] ; }
Transform the resource collection into an array.
Transform the resource collection into an array .