'Notice', 'type' => 'placeholder', 'label' => new HtmlString('You can use this extension to create custom frontend pages, go to Pages to get started.'), ], ]; } catch (\Exception $e) { return [ [ 'name' => 'Notice', 'type' => 'placeholder', 'label' => new HtmlString('You can use this extension to create custom frontend pages, you\'ll need to enable this extension above to get started.'), ], ]; } } public function enabled() { // Run migrations Artisan::call('migrate', ['--path' => 'extensions/Others/Pages/database/migrations', '--force' => true]); } public function boot() { // Register routes require __DIR__ . '/routes.php'; View::addNamespace('others.pages', __DIR__ . '/resources/views'); // Register livewire \Livewire\Livewire::component('extensions.others.pages.show', Page::class); Event::listen('navigation', function () { if (ModelsPage::where('visible', true)->where('navigation', 'top')->count() == 0) { return; } $pages = ModelsPage::where('visible', true)->where('navigation', 'top')->orderBy('sort')->get(); return $this->toNavigation($pages); }); Event::listen('navigation.account-dropdown', function () { if (ModelsPage::where('visible', true)->where('navigation', 'account_dropdown')->count() == 0) { return; } $pages = ModelsPage::where('visible', true)->where('navigation', 'account_dropdown')->orderBy('sort')->get(); return $this->toNavigation($pages); }); Event::listen('navigation.dashboard', function () { if (ModelsPage::where('visible', true)->where('navigation', 'dashboard')->count() == 0) { return; } $pages = ModelsPage::where('visible', true)->where('navigation', 'dashboard')->orderBy('sort')->get(); return $this->toNavigation($pages); }); } private function toNavigation($pages) { $navigation = []; foreach ($pages as $page) { if ($page->visibility == 'client' && !auth()->check()) { continue; } if ($page->visibility == 'admin' && (!auth()->check() || is_null(auth()->user()->role))) { continue; } $navigation[] = [ 'name' => $page->title, 'route' => 'extensions.others.pages', 'params' => ['fallbackPlaceholder' => $page->slug], ]; } return $navigation; } }