How to pass data to all views in Laravel 5?

Define a function which will return the data which you wanted to use on every view page.

Like I defined my function in ProductServiceProvider.php

Now call getTrendingProducts() function inĀ AppServiceProvider.php which is under App/Providers direcory.

Now you will be able to useĀ $trandingProducts variable on every view of application.

Share This: