In this article i will let you know how to get homepage or site url in your controller, blade file, model etc. So as we know we may need to get base url of our website then we can get it several way in laravel 5 application.
Here, i will give you several examples of how to get base url in view file or controller etc. So you can use any as your requirement or work as you expect. So simply let's see bellow examples one by one.
Example 1:
Route::get('site-url', function () {
dd(\URL::to('/'));
});
Example 2:
Route::get('site-url', function () {
dd(url('/'));
});
Example 3:
Route::get('site-url', function () {
dd(asset('/'));
});
Example 4:
Route::get('site-url', function () {
dd(config('app.url'));
});
I hope you found your best...
Do you like below Tutorials ?
- PHP Convert Date String to Datetime Object
- Laravel Validation Different Value Example
- Jquery Redirect to URL After Specific Time Example
- User Roles and Permissions in Laravel Example
- How to Get Value of Selected Option in Vue JS?
- Laravel Change Password OLD Password Validation Example
- Vue JS Get String Length Example
- How to Active and Inactive Status in Laravel?