app/Http/ViewComposers/ClientHeaderComposer.php
// In this class, we assign the global variables, with $view->with()// Note: there's no Artisan command like "php artisan make:composer", you need to create this class manually// in whatever folder you choose. In this case, author created app/Http/ViewComposers folder and namespace. namespace App\Http\ViewComposers; class ClientHeaderComposer{ public function compose(View $view) { $clients = Client::findOrFail($view->getData()['client']['id']); $contact_info = $clients->contacts()->first(); $contact = $clients->user; $view->with('contact', $contact)->with('contact_info', $contact_info); }}