Saturday 10 December 2022

Request Laravel Compare Route

Example of getting route name and path in Laravel 8




//get all uri except domain host
request()->getRequestUri();

//raw path info after domain and protocal in uri
request()->getPathInfo();

//trim the slash "/" inside uri
request()->path();

//check route name w/o group
request()->is('licenses');

//get and check route name
request()->route()->named('licenses.index')
  
//get first segment of path url
request()->segments()[0]



Example of Use :







No comments:

Post a Comment