Home » laravel Views share Variable multiple to controller

laravel Views share Variable multiple to controller

Today, We want to share with you laravel Views share Variable multiple to controller.In this post we will show you how to pass data from one view to another view in laravel, hear for Sharing Data Between Views Using Laravel View Composers we will give you demo and example for implement.In this post, we will learn about Use Laravel View Composer to share data in partial views with an example.

Read Also:  Passing data to views from routes in Laravel

laravel Views share Variable multiple to controller

There are the Following The simple About laravel Views share Variable multiple to controller Full Information With Example and source code.

As I will cover this Post with live Working example to develop Pass a variable on multiple views, so the How to share Variable with all Views in Laravel? for this example is following below.

Step 1: Create a Laravel Route

First of all Lets us create two main Laravel routes:

Read Also:  Laravel Load multiple views in same controller

# routes/web.php

Route::get('product', function () {
    return view('product');

Route::get('transaction', function () {
    return view('transaction');

Step 2: Create Blade View

Next, We have simple create two fresh views:


    <h1>product Page</h1>
    <p><?= $comman_data ?></p>


    <h1>Transaction Page</h1>
    <p><?= $comman_data ?></p>

Step 3: Share Variables


public function boot()
   // add this
    view()->share('comman_data', 'This is shared data');

Step 4: Testing


Web Programming Tutorials Example with Demo

Read :

Read Also:  Laravel Passing Multiple Variables from Controller to View


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

I hope you get an idea about laravel Views share Variable multiple to controller.
I would like to have feedback on my infinityknow.com 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:  Laravel Convert object Array JSON String Example
  2. Read Also:  Laravel Global variable Sharing Data with all views
  3. Read Also:  Installing Windows step by step - Install Windows 7
  4. Read Also:  Laravel passing multiple variables Across multiple pages
  5. Read Also:  Laravel 5.6 Share Variable With Display Data in View
  6. Read Also:  Simple Vuejs Currency Converter Example
  7. Read Also:  Top 10 Advanced Laravel Interview Questions Answers
  8. Read Also:  Clear Caches Laravel 5.7 using command line
  9. Read Also:  C# Comments Tutorial with Examples
  10. Read Also:  CSS Modal Popup Box Window Plugins

Leave a Comment

Your email address will not be published. Required fields are marked *