2021-10-01 13:40:37 +02:00
|
|
|
<?php
|
|
|
|
|
2021-11-07 21:57:22 +01:00
|
|
|
namespace App\Api\v1\Resources;
|
2021-10-01 13:40:37 +02:00
|
|
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
2022-09-07 17:54:27 +02:00
|
|
|
/**
|
|
|
|
* @property mixed $id
|
|
|
|
* @property string $name
|
|
|
|
* @property string $email
|
|
|
|
*/
|
2021-10-01 13:40:37 +02:00
|
|
|
class UserResource extends JsonResource
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Transform the resource into an array.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toArray($request)
|
|
|
|
{
|
|
|
|
return [
|
2022-11-17 16:46:29 +01:00
|
|
|
'id' => $this->when(!is_null($request->user()), $this->id),
|
2021-10-01 13:40:37 +02:00
|
|
|
'name' => $this->name,
|
2022-11-17 16:46:29 +01:00
|
|
|
'email' => $this->when(!is_null($request->user()), $this->email),
|
2021-10-01 13:40:37 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|