|
2 | 2 |
|
3 | 3 | namespace Botble\LogViewer\Providers;
|
4 | 4 |
|
| 5 | +use Botble\Base\Facades\DashboardMenu; |
| 6 | +use Botble\Base\Facades\PanelSectionManager; |
| 7 | +use Botble\Base\PanelSections\Manager; |
| 8 | +use Botble\Base\PanelSections\PanelSectionItem; |
| 9 | +use Botble\Base\PanelSections\System\SystemPanelSection; |
5 | 10 | use Botble\LogViewer\LogViewer;
|
6 | 11 | use Illuminate\Routing\Events\RouteMatched;
|
7 | 12 | use Botble\Base\Supports\Helper;
|
8 | 13 | use Botble\Base\Traits\LoadAndPublishDataTrait;
|
9 |
| -use Event; |
10 | 14 | use Illuminate\Support\ServiceProvider;
|
11 | 15 | use Botble\LogViewer\Contracts;
|
12 | 16 | use Botble\LogViewer\Utilities;
|
@@ -62,16 +66,31 @@ public function boot()
|
62 | 66 | ->loadMigrations()
|
63 | 67 | ->publishAssets();
|
64 | 68 |
|
65 |
| - Event::listen(RouteMatched::class, function () { |
66 |
| - dashboard_menu()->registerItem([ |
67 |
| - 'id' => 'cms-plugin-system-logs', |
68 |
| - 'priority' => 7, |
69 |
| - 'parent_id' => 'cms-core-platform-administration', |
70 |
| - 'name' => 'plugins/log-viewer::log-viewer.menu_name', |
71 |
| - 'icon' => null, |
72 |
| - 'url' => route('log-viewer::logs.index'), |
73 |
| - 'permissions' => ['logs.index'], |
74 |
| - ]); |
75 |
| - }); |
| 69 | + if (version_compare('7.0.0', get_core_version(), '>=')) { |
| 70 | + $this->app['events']->listen(RouteMatched::class, function () { |
| 71 | + DashboardMenu::registerItem([ |
| 72 | + 'id' => 'cms-plugin-log-viewer', |
| 73 | + 'priority' => 7, |
| 74 | + 'parent_id' => 'cms-core-platform-administration', |
| 75 | + 'name' => 'plugins/log-viewer::log-viewer.system_logs', |
| 76 | + 'icon' => null, |
| 77 | + 'url' => route('log-viewer::logs.index'), |
| 78 | + 'permissions' => ['log-viewer::logs.index'], |
| 79 | + ]); |
| 80 | + }); |
| 81 | + } else { |
| 82 | + PanelSectionManager::group('system')->beforeRendering(function (Manager $manager) { |
| 83 | + $manager |
| 84 | + ->registerItem( |
| 85 | + SystemPanelSection::class, |
| 86 | + fn() => PanelSectionItem::make('system.log-viewer') |
| 87 | + ->setTitle(trans('plugins/log-viewer::log-viewer.system_logs')) |
| 88 | + ->withDescription(trans('plugins/log-viewer::log-viewer.system_logs_description')) |
| 89 | + ->withIcon('ti ti-report') |
| 90 | + ->withPriority(9980) |
| 91 | + ->withRoute('log-viewer::logs.index') |
| 92 | + ); |
| 93 | + }); |
| 94 | + } |
76 | 95 | }
|
77 | 96 | }
|
0 commit comments