Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects

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.

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:

# 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:

  AngularJs Clone Array

resources/views/product.blade.php

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

resources/views/transaction.blade.php

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

Step 3: Share Variables

app/Providers/AppServiceProvider.php

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

Step 4: Testing

localhost:8000/product
localhost:8000/transaction

Web Programming Tutorials Example with Demo

Read :

Summary

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.

  Preview Image before Upload using vuejs

Leave a Reply

avatar
  Subscribe  
Notify of