Returning multiple variables with view::share( ) - Laravel 5.1

You can pass an array of data,

$data = array(
    'currentUser' => $currentUser,
    'needToBePassed' => $needToBePassed,
);
View::share('data', $data);

I know the question is already answered, but maybe I can still help a few people by adding this solution. This way you don't have to change all your views.

I was looking for a way to solve this issue without changes all my views.

$currentUser = Auth::user();
$needToBePassed = "Lorem Ipsum";

View::share(['currentUser' => $currentUser, 'needToBePassed' => $needToBePassed]);

Tags:

Php

Laravel

Blade