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 [
|
2023-02-17 17:12:53 +01:00
|
|
|
'id' => $this->when(! is_null($request->user()), $this->id),
|
|
|
|
'name' => $this->name,
|
|
|
|
'email' => $this->when(! is_null($request->user()), $this->email),
|
|
|
|
'is_admin' => $this->when(! is_null($request->user()), $this->is_admin),
|
2021-10-01 13:40:37 +02:00
|
|
|
];
|
|
|
|
}
|
2022-11-22 15:15:52 +01:00
|
|
|
}
|