2FAuth/app/Api/v1/Resources/UserResource.php

23 lines
501 B
PHP

<?php
namespace App\Api\v1\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Auth;
class UserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'name' => $this->name,
'email' => $this->when(Auth::guard('api')->user(), $this->email),
];
}
}