How to Redirect Route with Querystring in Laravel?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this post i would like to share with you How to Redirect Route with Querystring in Laravel. Most of time, we are working on back-end and we need to redirect route or url from controller with pass query string parameter. So on laravel provide us very simple way to pass query to string parameter with redirect route. Now in the following example we can see how it is possible.

So now in Bellow example we can see how i can added highchart() function for route haddle. Now in that function i will redirect “home” route with 2 parameter as query string like id and item_id, so on url will be like this way:

http://test.hd/home?id=2&itemid=3

And controller function will be this way:

Example:

namespace App\Http\Controllers;


use Illuminate\Http\Request;
use App\View;


class HomeController extends Controller
{
	

    public function highchart()
    {


        $viewer = View::all();


        return redirect()->route('home',['id'=>2,'itemid'=>3])
                ->with('info','We are in home back.');
    }


}

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →