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.
Why namespace And use Keywords Used In PHP
Sass or SCSS @mixin vs @extends vs Placeholder (%)
Make Laravel Controllers Slim By Skimming Form Validation Request
@stack @push and @prepend In Laravel Blade
Relationship Table Data With Route Model Binding In Laravel
Install Packages Parallel For Faster Development In Composer
Global Data In All Laravel Blade Pages
Manipulate HTML Using DOMDocument In PHP
Install RabbitMQ with Docker & Running with NodeJS
Dependency Dropdowns With Javascript And PHP
What Is Laravel Resourceful Controllers?
Detect AdBlocker With Javascript And Increase Website Ads Revenue