adrema/app/Http/Resources/UserResource.php

45 lines
876 B
PHP

<?php
namespace App\Http\Resources;
use App\Lib\HasMeta;
use App\User;
use Illuminate\Http\Resources\Json\JsonResource;
use Storage;
/**
* @mixin User
*/
class UserResource extends JsonResource
{
use HasMeta;
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
*
* @return array<string, mixed>
*/
public function toArray($request): array
{
return [
'firstname' => $this->firstname,
'lastname' => $this->lastname,
'avatar_url' => $this->getGravatarUrl(),
'email' => $this->email,
'id' => $this->id,
'avatar' => [
'src' => Storage::url('avatar.png'),
],
];
}
public static function meta(): array
{
return [
'links' => []
];
}
}