Como passar o valor em app.blade
//create a service provider
php artisan make:provider ComposerServiceProvider
//register the app service provider in providers array of config/app.php
App\Providers\ComposerServiceProvider::class,
//pass the data you want to share in views
<?php
namespace App\Providers;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class ComposerServiceProvider extends ServiceProvider {
public function boot()
{
View::composer('*', function($view){
$data = Some logic here ; //eg User::all();
$view->with('data', $data); // 'data' is value to be used in views 'data' = $data
});
}
public function register()
{
//
}
}
Code Alchemy