Laravel route not defined error

前端 未结 2 509
野的像风
野的像风 2021-01-25 05:24

I keep getting route not defined error and if I use url() I get server can not provide a secure connection error. I hope I can get some help.

route

2条回答
  •  -上瘾入骨i
    2021-01-25 05:56

    To call a route by name, you should use the route function and add the parameters in an array as the second parameter.

    route('product-show', [$table_name, $product->item_id])
    

    The reason you get a route not defined error is that you are generating the url /product-show/{table_name}/{product_id} and the actual url is /show/{table_name}/{product_id}. Also, adding the parameters manually is bad practice when there are many helper functions that do this for you.

提交回复
热议问题