Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (26 sloc) 772 Bytes
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
use function sprintf;
class CommentResource extends JsonResource
{
public function toArray($request): array
{
return [
'id' => $this->resource['id'],
'body' => $this->resource['body'],
"_links" => [
'self' => [
'href' => sprintf('/comments/%s', $this->resource['id'])
]
],
'_embedded' => [
'user' => new UserResource([
'user_id' => $this->resource['user_id'],
'user_name' => $this->resource['user_name']
])
],
];
}
}
You can’t perform that action at this time.