Laravel Code Reorder Hard +35 XP
API Resource Route
Arrange creating and responding to a resource.
Click lines in the correct order
Available lines4 left
Your order
Click lines above to build your solution.
Show answer and explanation
Answer: public function store(StorePostRequest $request)
{
$post = Post::create($request->validated());
return new PostResource($post);
}
Method signature, opening brace, create the resource, return the API resource response.
Hint: Method declaration first, then logic.
What this challenge tests
Code Reorder in Laravel: api-resources, controllers.