I forgot to say that i tried pass the id with an associative arrayroute('post.like', ['id'=>$id]) but still doesnt work
. Also i have change the route like so : Route::post('/post/{post}/like', [LikeController::class, 'postLike'])->name('post.like');
to match the names but nothing...
You are using route-model binding. When you use it, variable names in route parameters and controller arguments should match with each other. Either change your route to /post/{post}/like
or change the controller parameter variable to $id
.
If route parameter and controller argument names matching then you don't need to pass route parameters as an associative array. If you still want to use an associative array then you should pass it matching with route parameter name, like ['post' => $id]
.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community