tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.94k stars 250 forks source link

How can I put the default route in the beginning of the route ? #418

Closed jeanali closed 3 years ago

jeanali commented 3 years ago

Is there any way to put default to the route?

Like have this structure route('stores.products.index'); in my route & I need to make the stores defult in the route and being like this route('products.index'); without each time put stores each time!

I'm using this pacakge with inertiajs

bakerkretzmar commented 3 years ago

Yes this is possible, you would set it up in your Laravel app. It's in the docs under URL Generation > Default Parameters.

Basically, in a middleware or service provider, call URL::defaults(['stores' => 'your-default-value']);. Note that this will affect all route parameters called stores, in all routes.

Closing because this isn't directly a Ziggy concern, but feel free to reply again if you have any other questions!