Support the ongoing development of Laravel.io →
posted 3 years ago
Last updated 2 years ago.
0

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...

0

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].

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Vasilis bill5play Joined 17 Jun 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.