coderello / laravel-shared-data

📦 An easy way to share the data from your backend to the JavaScript.
https://coderello.com/docs/laravel-shared-data/1.0/sharing-data
MIT License
321 stars 22 forks source link

Share lazily #9

Closed hivokas closed 5 years ago

hivokas commented 5 years ago

I'm thinking about adding an ability to share the values lazily using Closures.

share(function() {
    return ['user' => auth()->user()];
});

// or

share('user', function() {
    return auth()->user();
});