Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (27 sloc) 828 Bytes
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Http\Resources\ArticleResource;
use Illuminate\Http\Request;
final class ArticlePayloadAction extends Controller
{
public function __invoke(Request $request)
{
$resource = new ArticleResource([
'id' => 1,
'title' => 'Laravel REST API',
'comments' => [
[
'id' => 2134,
'body' => 'awesome!',
'user_id' => 133345,
'user_name' => 'Application Developer',
]
],
'user_id' => 13255,
'user_name' => 'User1'
]);
return $resource->response($request)
->header('content-type', 'application/hal+json');
}
}
You can’t perform that action at this time.