Created
January 18, 2023 16:06
-
-
Save Tynael/6164f9bc474c95049df47bb6f0b383ef to your computer and use it in GitHub Desktop.
How to Get Current URL Inside Blade Templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head></head> | |
<body> | |
<p> | |
<!-- Our URL: http://localvaren.com/home?param=neutrondev --> | |
<!-- | |
Get the current URL | |
Output: http://localvaren.com/home | |
--> | |
{{ request()->url() }} | |
{{ Request::url() }} | |
<!-- | |
Get the full URL | |
Output: http://localvaren.com/home?param=neutrondev | |
--> | |
{{ request()->fullUrl() }} | |
{{ Request::fullUrl() }} | |
<!-- | |
Get only the path | |
Output: home | |
--> | |
{{ request()->path() }} | |
{{ Request::path() }} | |
</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example used in https://neutrondev.com/get-current-url-blade-template/