How to Pass Data to All Views in Laravel -

Steps to Pass Data to All Views in Laravel

use Illuminate\Support\Facades\View;
<?php 
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use DB;
use Illuminate\Support\Facades\View;
class AppServiceProvider extends ServiceProvider
{ /** * Bootstrap any application services. * * @return void */ public function boot()
{
//
$categories=DB::table('categories')->get(); View::share('categories',$categories);
}
/** * Register any application services. * * @return void */ public function register()
{
//
}
}

--

--

--

Hi, This is Biplab and I am web developer well versed in PHP and other open source technologies. I am here to share my experience with the community.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bipsmedium

Bipsmedium

Hi, This is Biplab and I am web developer well versed in PHP and other open source technologies. I am here to share my experience with the community.

More from Medium

Laravel 8 Group By Query Example

Laravel Security Vulnerabilities Challenge And How to Address Them Using

How To Generate QR code in laravel 8 — Phpflow.com

Github | Project Documentation Compendium | Changelog Templates