koel/app/Http/Resources/UserResource.php

28 lines
617 B
PHP
Raw Normal View History

2022-06-10 10:47:46 +00:00
<?php
namespace App\Http\Resources;
use App\Models\User;
use Illuminate\Http\Resources\Json\JsonResource;
class UserResource extends JsonResource
{
public function __construct(private User $user)
{
parent::__construct($user);
}
/** @return array<mixed> */
public function toArray($request): array
{
return [
'type' => 'users',
'id' => $this->user->id,
'name' => $this->user->name,
'email' => $this->user->email,
'avatar' => $this->user->avatar,
'is_admin' => $this->user->is_admin,
];
}
}