Skip to main content

Laravel Get Base URL in Controller Example

Laravel Get Base URL in Controller

Hi Dev,

Today, I will learn to you how to create laravel get base url in the controller, we will create get base url in the controller. We will show a step by step simple get base url in laravel.

You may use the url or fullurl methods to get base url in the controller. the url method will return the url without the query string, while the full url method includes the query string using get base url in the controller. you can get using url facade methods to get base url in the controller.

Here examples following different types to get base url in the controller.

Example: 1Now In this example url() method to get url in controller

/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$url = url()->full();
print_r($url);
}
Example: 2Now in this example in request facade of url method using get url in controller

/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$url = \Request::url();
print_r($url);
}
Example: 3Here in this example in request facade of fullUrl method using get url in controller

/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$url = \Request::fullUrl();
print_r($url);
}
Example: 4Now In this example in url facade of current method using get url in controller

/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$url = \URL::current();
print_r($url);
}
It will help you...

Comments

Popular posts from this blog

Laravel Validation Image Example

Hi Guys, Today, I will learn you to create validation image in laravel.we will show example of laravel validation image.The file under validation must be an image (jpg, jpeg, png, bmp, gif, svg, or webp). Here, I will give you full example for simply image validation in laravel bellow. solution $request->validate([ 'file' => 'image' ]); Route : routes/web.php Route::get('form/create','FromController@index'); Route::post('form/store','FromController@store')->name('form.store'); Controller : app/Http/Controllers/BlogController.php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Blade; use App\Models\User; use App\Models\Post; class FromController extends Controller { /** * Write code on Method * * @return response() */ public function create() { return view('form'); } /** * Write code on Method ...

React Native Flexbox Tutorial With Example

Hi Dev, Today, I will learn you how to create flexbox in react native. You can easily create flexbox in react native. First i will import namespace View , after I will make flexbox using View tag in react native. Here, I will give you full example for simply display flexbox using react native as bellow. Step 1 - Create project In the first step Run the following command for create project. expo init flexbox Step 2 - App.js In this step, You will open App.js file and put the code. import React, { Component } from 'react' import { View, StyleSheet } from 'react-native' const Home = (props) => { return ( <View style = {styles.container}> <View style = {styles.redbox} /> <View style = {styles.greenbox} /> <View style = {styles.corolbox} /> <View style = {styles.purplebox} /> </View> ) } export default Home const styles = StyleSheet.create ({ container: { flexDirection:...

Laravel Cron Job Task Scheduling Example

Laravel Cron Job Task Scheduling Example Hi Dev In this blog, I will learn how to create Cron Job Task Scheduling in laravel we will give you simple example of cron job task scheduling with laravel. we will create example step by step of cron job using laravel task scheduling. You can easy create a cron job task scheduling in laravel.Why we have to use cron job? and what is benefit to use cron jobs in laravel and how to setup cron job in laravel?, If you have this question then i will explain why.Many times we need to send notifications or send email automatically to users for update property or items. So at that time you can define some basic logic for each days, hours etc can run and send email notification. Here blow the example of cron job task scheduling Step 1 : Install Laravel Application we are going from scratch, So we require to get fresh Laravel application using bellow command, So open your terminal OR command prompt and run bellow command: composer create-project --p...