sahar_mkr started a new conversation+100 XP
4mos ago
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);
}
sahar_mkr liked a comment+100 XP
5mos ago
For anyone else having this problem, the solution is in the Livewire Quickstart Guide:
php artisan livewire:layout
If you are creating a new basic Laravel project to try Livewire ( no Jetstream or similar), you do not get a default layout. This command will create one in the location expected by Livewire.