Passing data to views from routes in Laravel

Today, We want to share with you Passing data to views from routes in Laravel.In this post we will show you , hear for Laravel passing data from view to controller we will give you demo and example for implement.In this post, we will learn about how to pass variable from view to route in laravel with an example.

Passing data to views from routes in Laravel

There are the Following The simple About Passing data to views from routes in Laravel Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel pass multiple arrays to view, so the some laravel pass data to view from controller for this example is following below.

More Details for Pakainfo Blog:Free Download Example –


Route::get('/', function(){
   return view('welcome',['name'=>'Pakainfo','age'=>3]); 

<h1>Laravel Hello {{$name}}</h1>
<p>Your Age is {{$age}}</p>


Route::get('/', function(){
   return view('welcome')->with('name','Pakainfo'); 


//Welcome view
Route::get('/', function(){
    $name = 'Pakainfo';
    return view('welcome',compact('name')); 

//Data View
Route::get('/data', function(){
    $name = 'Pakainfo';
    $age = '28';
    return view('data',compact('name','age')); 

//Sending as List
Route::get('/listdata', function(){
    $tasks = [
        'Write Code',
        'Unit Test',
    return view('listdata',compact('tasks')); 

simple Laravel Passing data from controller to view in Laravel



use App\Products;
use DB;
use Illuminate\Http\Request;

class HomeController extends Controller
    public function __construct()
     * Display a listing of the resource.
     * @return \Illuminate\Http\Response
    public function index(Request $request)
        $flagstatus = "Normal";
        $status_list = DB::table('statuses')->whereNull('deleted_at')->pluck("name","id");
        return view('products.index',compact('status_list','flagstatus'));


@section('title', 'Dashboard')

<div class="filter-bx">
    <div class="row">
        <div class="col-lg-3 col-sm-6">
            <div class="form-group">
                <label>Filter By({{$flagstatus}})</label>
                <select id="statusFilter" name="search_group_filter" class="form-control">
                    <option value="0">All Status</option>
                    @foreach ($status_list as $cat => $value)
                        <option value="{{ $cat }}"> {{ $value }}</option>

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Passing data to views from routes in Laravel.
I would like to have feedback on my Pakainfo blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   laravel Views share Variable multiple to controller
  2.   PHP - MySQLi Insert Update Delete CRUD Operation using AngularJS
  3.   Vue js Axios HTTP Get Method Example Tutorial From Scratch
  4.   Laravel 5.8 Global Blade view variable
  5.   Laravel 6 schema Timestamps Example
  6.   Implement Read More Read Less Functionality Using jQuery
  7.   Angular 6 SEO (Search Engine Optimization) Tutorial
  8.   Laravel Load multiple views in same controller
  9.   how to upload image in php and store in database and folder?
  10.   Laravel Route pass multiple Parameters Examples