Whenever I try to create a new route with a parameter it gives me a 404 error. However, when I delete the parameters, it all works just fine. I tried all the artisan commands:
route:clear
cache:clear
config:cache
composer dump-autoload
When I check route:list, the routes are also there. At this point, I'm starting to pull my hair out. I just don't know what's going on here.
Can you give us an example of the route you defined and the route you are trying to visit?
If you define a route with a parameter Laravel might start searching your database for a model to match that parameter. This is called route model binding https://laravel.com/docs/8.x/routing#route-model-binding. If the model is not found it throws a ModelNotFoundException which shows a 404 on your screen.
@Sinnbeck I made a mistake in my GetRouteKeyName function. Where It should have returned "invoice_id", it returned "invoice_id ". After removing the extra space at the end, the issue was resolved.
After checking my model I see that my function "getRouteKeyName()" has an extra added space in the return value. I'm crying rn lol. Issue is resolved now! Thank you for your help!
public function getRouteKeyName() {
return 'invoice_id';
}