
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.
Stripe Payment Integration With Laravel
Move Uploaded Files From Local Computer Or Server To Amazon S3 Bucket In PHP
Factories To Speed Up Test-Driven Development In Laravel
Laravel Clear Cache Of Route, View, Config Command
GitHub Login With PHP Laravel Socialite
Global Data In All Laravel Blade Pages
Route Model Binding In Laravel & Change Default Column id To Another Column
Search Engine Optimization Concepts
Sass or SCSS @mixin vs @extends vs Placeholder (%)
Setup AMP (Accelerated Mobile Pages) In PHP Laravel
Test Your Local Developing Laravel Web Application From Phone Browser Without Any Software
What Is HTTP? Different HTTP Methods And Status Codes Explained With Examples