Skip to content

Commit fef7f09

Browse files
Botble 7 compatible
1 parent ac1c653 commit fef7f09

File tree

3 files changed

+37
-50
lines changed

3 files changed

+37
-50
lines changed

plugin.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"provider": "Botble\\LogViewer\\Providers\\LogViewerServiceProvider",
66
"author": "Botble Technologies",
77
"url": "https://botble.com",
8-
"version": "1.2.0",
8+
"version": "1.3.0",
99
"description": "Provides a log viewer for Botble CMS"
1010
}

src/Providers/LogViewerServiceProvider.php

+31-12
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
namespace Botble\LogViewer\Providers;
44

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;
510
use Botble\LogViewer\LogViewer;
611
use Illuminate\Routing\Events\RouteMatched;
712
use Botble\Base\Supports\Helper;
813
use Botble\Base\Traits\LoadAndPublishDataTrait;
9-
use Event;
1014
use Illuminate\Support\ServiceProvider;
1115
use Botble\LogViewer\Contracts;
1216
use Botble\LogViewer\Utilities;
@@ -62,16 +66,31 @@ public function boot()
6266
->loadMigrations()
6367
->publishAssets();
6468

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+
}
7695
}
7796
}

src/Tables/StatsTable.php

+5-37
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,12 @@
88

99
class StatsTable extends Table
1010
{
11-
/**
12-
* Make a stats table instance.
13-
*
14-
* @param array $data
15-
* @param LogLevelsContract $levels
16-
* @param string|null $locale
17-
* @return StatsTable
18-
*/
19-
public static function make(array $data, LogLevelsContract $levels, $locale = null)
11+
public static function make(array $data, LogLevelsContract $levels, string $locale = null): static
2012
{
2113
return new self($data, $levels, $locale);
2214
}
2315

24-
/**
25-
* Get json chart data.
26-
*
27-
* @param string|null $locale
28-
* @return array|false|string
29-
*/
30-
public function totalsJson($locale = null)
16+
public function totalsJson(string $locale = null): bool|array|string
3117
{
3218
$this->setLocale($locale);
3319

@@ -46,13 +32,7 @@ public function totalsJson($locale = null)
4632
return json_encode(array_values($json), JSON_PRETTY_PRINT);
4733
}
4834

49-
/**
50-
* Prepare table header.
51-
*
52-
* @param array $data
53-
* @return array
54-
*/
55-
protected function prepareHeader(array $data)
35+
protected function prepareHeader(array $data): array
5636
{
5737
return array_merge_recursive(
5838
[
@@ -63,13 +43,7 @@ protected function prepareHeader(array $data)
6343
);
6444
}
6545

66-
/**
67-
* Prepare table rows.
68-
*
69-
* @param array $data
70-
* @return array
71-
*/
72-
protected function prepareRows(array $data)
46+
protected function prepareRows(array $data): array
7347
{
7448
$rows = [];
7549

@@ -80,13 +54,7 @@ protected function prepareRows(array $data)
8054
return $rows;
8155
}
8256

83-
/**
84-
* Prepare table footer.
85-
*
86-
* @param array $data
87-
* @return array
88-
*/
89-
protected function prepareFooter(array $data)
57+
protected function prepareFooter(array $data): array
9058
{
9159
$footer = [];
9260

0 commit comments

Comments
 (0)