diff --git a/composer.json b/composer.json index 6677f76..668b4e9 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,6 @@ ], "require": { "igaster/laravel-theme": "^2.0.12", - "acacha/user": "^0.2.2", "creativeorange/gravatar": "^1.0", "orchestra/asset": "^3.6" }, diff --git a/resources/themes/adminlte/views/layouts/partials/sidebar.blade.php b/resources/themes/adminlte/views/layouts/partials/sidebar.blade.php index 7bdc55f..27b3cbb 100644 --- a/resources/themes/adminlte/views/layouts/partials/sidebar.blade.php +++ b/resources/themes/adminlte/views/layouts/partials/sidebar.blade.php @@ -15,6 +15,7 @@
{{ $user->name ?: 'Nobody' }} + @isset($user->lastlogin)Last On: {{ $user->lastlogin->format('Y-m-d H:i') }}@endisset
diff --git a/src/GuestUser.php b/src/GuestUser.php new file mode 100644 index 0000000..cc4880e --- /dev/null +++ b/src/GuestUser.php @@ -0,0 +1,29 @@ +share('loggedin',auth()->check()); + view()->share('user', auth()->user() ?: new \Leenooks\GuestUser); + + return $next($request); + } +} \ No newline at end of file diff --git a/src/Providers/LeenooksServiceProvider.php b/src/Providers/LeenooksServiceProvider.php index 468ba11..43d1b9f 100644 --- a/src/Providers/LeenooksServiceProvider.php +++ b/src/Providers/LeenooksServiceProvider.php @@ -2,6 +2,7 @@ namespace Leenooks\Providers; +use Leenooks\Http\Middleware\GuestUser; use Illuminate\Routing\Router; use Illuminate\Support\ServiceProvider; @@ -12,60 +13,58 @@ use Illuminate\Support\ServiceProvider; */ class LeenooksServiceProvider extends ServiceProvider { - private $_path = ''; + private $_path = ''; - /** - * Bootstrap the application services. - * - * @param Router $router - */ - public function boot(Router $router) - { - $this->loadViewsFrom($this->_path.'/resources/themes/adminlte/views/', 'adminlte'); - $this->loadTranslationsFrom($this->_path.'/resources/themes/adminlte/lang/', 'adminlte_lang'); + /** + * Bootstrap the application services. + * + * @param Router $router + */ + public function boot(Router $router) + { + $router->pushMiddlewareToGroup('web',GuestUser::class); - // Enable a recusive() collection function so that we can just arrives in config/*.php - \Illuminate\Support\Collection::macro('recursive', function () { - return $this->map(function ($value) { - if (is_array($value) || is_object($value)) { - return collect($value)->recursive(); - } + $this->loadViewsFrom($this->_path.'/resources/themes/adminlte/views/', 'adminlte'); + $this->loadTranslationsFrom($this->_path.'/resources/themes/adminlte/lang/', 'adminlte_lang'); - return $value; + // Enable a Collect::recursive() function + \Illuminate\Support\Collection::macro('recursive', function () { + return $this->map(function ($value) { + + if (is_array($value) || is_object($value)) { + return collect($value)->recursive(); + } + + return $value; + }); }); - }); - } + } - /** - * Register the application services. - * - * @return void - */ - public function register() - { - if (! $this->_path) { - $this->_path = realpath(__DIR__.'/../../'); - } - } + /** + * Register the application services. + * + * @return void + */ + public function register() + { + if (! $this->_path) { + $this->_path = realpath(__DIR__.'/../../'); + } + } - /** - * Views copy path. - * - * @return array - */ - public function views() - { - return [ - $this->_path.'/resources/views/auth' => - resource_path('views/vendor/adminlte/auth'), - $this->_path.'/resources/views/errors' => - resource_path('views/vendor/adminlte/errors'), - $this->_path.'/resources/views/layouts' => - resource_path('views/vendor/adminlte/layouts'), - $this->_path.'/resources/views/home.blade.php' => - resource_path('views/vendor/adminlte/home.blade.php'), - $this->_path.'/resources/views/welcome.blade.php' => - resource_path('views/welcome.blade.php'), - ]; - } -} + /** + * Views copy path. + * + * @return array + */ + public function views() + { + return [ + $this->_path.'/resources/views/auth' => resource_path('views/vendor/adminlte/auth'), + $this->_path.'/resources/views/errors' => resource_path('views/vendor/adminlte/errors'), + $this->_path.'/resources/views/layouts' => resource_path('views/vendor/adminlte/layouts'), + $this->_path.'/resources/views/home.blade.php' => resource_path('views/vendor/adminlte/home.blade.php'), + $this->_path.'/resources/views/welcome.blade.php' => resource_path('views/welcome.blade.php'), + ]; + } +} \ No newline at end of file