Level 2
I am quite confused with your code.
what is $this->response?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Kindly help me on how to write the api route on querying a single user. I have the one that returns all the records in the database.
This is the route
$api->group([ 'namespace' => 'App\Http\Controllers', 'middleware' => ['auth:api', 'cors'] ], function ($api)
{
$api->get( 'users', 'UserController@showOne', );
});
This is the controller
public function showOne( $id )
{
$user = $this->userRepository->getById( $id );
$response = $this->response->item( $user, new Transformer() );
return $response;
}
Please or to participate in this conversation.