Question: In laravel you can share data to a view like this: `view::share()`

I would like to fetch the data that is present in view::share in php.
I will for example add the following `view::share('scripts', [])` and i would like to add items to that "scripts" variable.

Is it possible to fetch the shared variables?

Answer: 
You can use the [`shared()`](https://laravel.com/api/5.3/Illuminate/View/Factory.html#method_shared) method to get an item from the shared data as:

```
view()->shared('key')

```

[Docs](https://laravel.com/api/5.3/Illuminate/View/Factory.html#method_shared)
I'd go with passing a collection instead of an array. It's gonna be easier for usage in your view later on.

if you do something like: 

```
$scripts = collect([
    'script 1',
    'script 2',
    'script 3',
]);

View::share('scripts', $scripts);

```

You can now do the following in your views: 

```
 @foreach ($scripts as $script)
     {{ $script }}
 @endforeach

```

Anyway, why do you want to do this? Are these scripts, javascript files? If they are, use a master page / template view and include all of your scripts on one page instead of adding them on each page like the example above.