Laravel has a request()->segment(x)
helper to let us get a part or a segment of a url.
As an example: let say we have the following url https://id.kodekativ.co/db/s/posting
. Parts or segments from the URL is counted from 1, 2, and so on..
So if we want to receive db segment from the url, we can do the following:
<?php
request()->segment(1);
Or if we want to receive s instead, we only need to change the segmentation parameter like the following:
<?php
request()->segment(2);