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.

Read Also:  jquery uncheck all checkboxes Multiple Checkbox Example

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

Read Also:  Build Event Calendar with jQuery , PHP & MySQL



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 :

Read Also:  Laravel Route pass multiple Parameters Examples


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. Read Also:  How To Pass Data To Views from controller In Laravel?
  2. Read Also:  echo and print difference in php
  3. Read Also:  Laravel Passing Multiple Variables from Controller to View
  4. Read Also:  laravel Views share Variable multiple to controller
  5. Read Also:  Laravel 5.8 Global Blade view variable
  6. Read Also:  Laravel Load multiple views in same controller
  7. Read Also:  Laravel 5.6 Share Variable With Display Data in View
  8. Read Also:  Laravel passing multiple variables Across multiple pages
  9. Read Also:  Golang Float64s function - Math function
  10. Read Also:  Increment Decrement with Laravel 6 Example