diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 85ca0a3..f7cb4f9 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -28,30 +28,31 @@ class AppServiceProvider extends ServiceProvider Inertia::version(function () { return md5_file(public_path('mix-manifest.json')); }); - Inertia::share('app.name', Config::get('app.name')); - Inertia::share('flash', function () { + + Inertia::share(function () { return [ - 'success' => Session::get('success'), + 'app' => [ + 'name' => Config::get('app.name'), + ], + 'auth' => [ + 'user' => Auth::user() ? [ + 'id' => Auth::user()->id, + 'first_name' => Auth::user()->first_name, + 'last_name' => Auth::user()->last_name, + 'email' => Auth::user()->email, + 'role' => Auth::user()->role, + 'account' => [ + 'id' => Auth::user()->account->id, + 'name' => Auth::user()->account->name, + ], + ] : null, + ], + 'flash' => [ + 'success' => Session::get('success'), + ], + 'errors' => Session::get('errors') ? Session::get('errors')->getBag('default')->getMessages() : (object) [], ]; }); - Inertia::share('errors', function () { - return Session::get('errors') ? Session::get('errors')->getBag('default')->getMessages() : (object) []; - }); - Inertia::share('auth.user', function () { - if (Auth::user()) { - return [ - 'id' => Auth::user()->id, - 'first_name' => Auth::user()->first_name, - 'last_name' => Auth::user()->last_name, - 'email' => Auth::user()->email, - 'role' => Auth::user()->role, - 'account' => [ - 'id' => Auth::user()->account->id, - 'name' => Auth::user()->account->name, - ], - ]; - } - }); $this->registerLengthAwarePaginator(); $this->registerCarbonMarcos(); diff --git a/composer.lock b/composer.lock index 7b4afb0..e37b7c5 100644 --- a/composer.lock +++ b/composer.lock @@ -216,16 +216,16 @@ }, { "name": "egulias/email-validator", - "version": "2.1.7", + "version": "2.1.8", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "709f21f92707308cdf8f9bcfa1af4cb26586521e" + "reference": "c26463ff9241f27907112fbcd0c86fa670cfef98" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/709f21f92707308cdf8f9bcfa1af4cb26586521e", - "reference": "709f21f92707308cdf8f9bcfa1af4cb26586521e", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/c26463ff9241f27907112fbcd0c86fa670cfef98", + "reference": "c26463ff9241f27907112fbcd0c86fa670cfef98", "shasum": "" }, "require": { @@ -269,7 +269,7 @@ "validation", "validator" ], - "time": "2018-12-04T22:38:24+00:00" + "time": "2019-05-16T22:02:54+00:00" }, { "name": "erusev/parsedown", @@ -427,12 +427,12 @@ "source": { "type": "git", "url": "https://github.com/inertiajs/inertia-laravel.git", - "reference": "1c9acd0f69587013c2c24889f6b67ef0c31e0233" + "reference": "cb019592946bc939f61291039b8e893da66dd6eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/inertiajs/inertia-laravel/zipball/1c9acd0f69587013c2c24889f6b67ef0c31e0233", - "reference": "1c9acd0f69587013c2c24889f6b67ef0c31e0233", + "url": "https://api.github.com/repos/inertiajs/inertia-laravel/zipball/cb019592946bc939f61291039b8e893da66dd6eb", + "reference": "cb019592946bc939f61291039b8e893da66dd6eb", "shasum": "" }, "require-dev": { @@ -467,7 +467,7 @@ "inertia", "laravel" ], - "time": "2019-05-21T19:24:05+00:00" + "time": "2019-05-22T11:08:52+00:00" }, { "name": "jakub-onderka/php-console-color", @@ -2268,7 +2268,7 @@ }, { "name": "Gert de Pagter", - "email": "backendtea@gmail.com" + "email": "BackEndTea@gmail.com" } ], "description": "Symfony polyfill for ctype functions",