* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace App\Http\Resources; use Illuminate\Http\Resources\Json\ResourceCollection; class UserCollection extends ResourceCollection { public function toArray($request) { return $this->collection->map(function ($item) { return [ 'nickname' => $item->name, 'email' => $item->email, ]; })->all(); } }