
Good content takes time and effort to come up with.
Please consider supporting us by just disabling your AD BLOCKER and reloading this page again.
Most of the time you might require some generic data which needs to be made available across all the Laravel Blade pages.
For example, you might need a count of categories in your sidebar.
To make data available generic across all the view pages one of the simplest ways is to add it in AppServiceProvider.php boot function as shown below
public function boot()
{
View::composer('*', function($view){
/** You can also add with some condition */
if(Session::has('user_details')){
$view->with('projectCountDetails', ProjectsController::projectCountDetails());
}
});
}
From the above code, we will be able to access the projectCountDetails
variable across all the view pages as shown below.
Hope this article helped you. Please share it with your friends.
Integrate Google Translate Into Your Website
Global Data In All Laravel Blade Pages
Unable to prepare route [{fallbackPlaceholder}] for serialization. Uses Closure In Laravel
Comment And Like System Using Disqus
Google reCAPTCHA Integration In PHP Laravel Forms
Laravel Custom Maintenance Page
Factories To Speed Up Test-Driven Development In Laravel
Create Custom 404 Page In Laravel
Free SSL Certificate In cPanel With ZeroSSL & Certbot
Client-Side DataTable, Adding Super Powers To HTML Table
Dependency Dropdowns With Javascript And PHP
Generate Sitemap in PHP Laravel
Create A Composer Package? Test It Locally And Add To Packagist Repository