adrema/app/Http/Resources/UserResource.php

32 lines
592 B
PHP
Raw Normal View History

2020-04-10 20:32:12 +02:00
<?php
namespace App\Http\Resources;
2023-02-13 15:56:20 +01:00
use App\User;
2020-04-10 20:32:12 +02:00
use Illuminate\Http\Resources\Json\JsonResource;
use Storage;
2022-01-02 12:32:57 +01:00
/**
2023-02-13 15:56:20 +01:00
* @mixin User
2022-01-02 12:32:57 +01:00
*/
2020-04-10 20:32:12 +02:00
class UserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
2022-03-11 20:19:17 +01:00
* @param \Illuminate\Http\Request $request
*
2023-02-13 15:56:20 +01:00
* @return array<string, mixed>
2020-04-10 20:32:12 +02:00
*/
2023-02-13 15:56:20 +01:00
public function toArray($request): array
2020-04-10 20:32:12 +02:00
{
return [
2022-02-19 18:06:07 +01:00
'name' => $this->name,
'email' => $this->email,
2020-04-10 20:32:12 +02:00
'avatar' => [
2022-03-11 20:19:17 +01:00
'src' => Storage::url('avatar.png'),
],
2020-04-10 20:32:12 +02:00
];
}
}