Level 63
The API route is probably protected ... with Sanctum ?
I want to test this api, here I can create a user but when I get to the controller it shows user is null, why this happens? this api works properly and is so simple but on the test the user created successfully but in controller it is null and makes test fail:
public function index(User $user)
{
return success('User data', (new UserResource($user));
}
this is my route:
Route::get('/user/{user}', [UserController::class, 'index']);
this is my test:
public function test_show_user_meta()
{
$this->withoutMiddleware();
$user= User::factory()->create();
$response = $this->get('api/user/' . $user->id);
dd($response);
}
Please or to participate in this conversation.