Press "Enter" to skip to content

Route patterns in laravel in a simple way

Sharing is caring!

We do not mind if things repeat once or twice. But, when it occurs, we tend to give it a nice place to stay.

In laravel routing too, we often come to situation where we are applying patterns in our route parameters. Though laravel offers very fluent syntax, it becomes tedious, when repeated.

Now, we can see clearly, that those //->where stuffs are purely repeating.

It can clearly be refactored separately so that we do not have to declare it anymore. Like,

Next, we can define our routes now like this.

No more where calling is necessary now.

Everything is awesome.