
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.
Simple Way To Create Resourceful API Controller In Laravel
Global Data In All Laravel Blade Pages
PHP Built-In Web Server & Testing Your Development Project In Mobile Without Any Software
Push Files To CPanel / Remote Server using FTP Software FileZilla
Redirect www to a non-www Website Or Vice Versa
What Is Method Chaining In PHP?
Multiple GIT Key Pairs Or Account In The Same Computer
GitHub Login With PHP Laravel Socialite
Generate RSS Feeds in PHP Laravel
Add Google ADS In AMP (Accelerated Mobile Pages) Website
SummerNote WYSIWYG Text Editor Save Images To Public Path In PHP Laravel
Firebase Cloud Messaging (FCM) Browser Web Push Notifications Using Javascript And PHP