@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('resource_logs', function (Blueprint $table) { |
|
| 16 | + Schema::create('resource_logs', function(Blueprint $table) { |
|
| 17 | 17 | $table->id(); |
| 18 | 18 | $table->string('resource'); |
| 19 | 19 | $table->string('log'); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | ->select(DB::raw('date(created_at) as date'), 'resource') |
| 32 | 32 | ->get(); |
| 33 | 33 | |
| 34 | - $labels = []; |
|
| 34 | + $labels = [ ]; |
|
| 35 | 35 | foreach (CarbonPeriod::create($from, $to) as $date) { |
| 36 | 36 | array_push($labels, $date->format('Y-m-d')); |
| 37 | 37 | } |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | protected function resourceLogCount($resource, $labels, $resourceLogs) |
| 52 | 52 | { |
| 53 | - $logCount = []; |
|
| 53 | + $logCount = [ ]; |
|
| 54 | 54 | foreach ($labels as $label) { |
| 55 | - $resourceCount = $resourceLogs->countBy(function ($resourceLogs) use ($resource, $label) { |
|
| 56 | - return $resourceLogs['resource'] == $resource && $resourceLogs['date'] == $label; |
|
| 55 | + $resourceCount = $resourceLogs->countBy(function($resourceLogs) use ($resource, $label) { |
|
| 56 | + return $resourceLogs[ 'resource' ] == $resource && $resourceLogs[ 'date' ] == $label; |
|
| 57 | 57 | }); |
| 58 | - array_push($logCount, count($resourceCount) > 1 ? $resourceCount[1] : 0); |
|
| 58 | + array_push($logCount, count($resourceCount) > 1 ? $resourceCount[ 1 ] : 0); |
|
| 59 | 59 | } |
| 60 | 60 | return $logCount; |
| 61 | 61 | } |
@@ -11,10 +11,10 @@ |
||
| 11 | 11 | |
| 12 | 12 | public function definition() |
| 13 | 13 | { |
| 14 | - $resources = ['cpu', 'memory', 'hardDisk', 'network', 'webServer']; |
|
| 14 | + $resources = [ 'cpu', 'memory', 'hardDisk', 'network', 'webServer' ]; |
|
| 15 | 15 | |
| 16 | 16 | return [ |
| 17 | - 'resource' => $resources[random_int(0, 4)], |
|
| 17 | + 'resource' => $resources[ random_int(0, 4) ], |
|
| 18 | 18 | 'log' => $this->faker->text() |
| 19 | 19 | ]; |
| 20 | 20 | } |
@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | use Illuminate\Support\Facades\Route; |
| 4 | 4 | |
| 5 | -Route::middleware(['check.access.to.monitoring.panel'])->group(function () { |
|
| 6 | - Route::get('/monitoring-panel', function () { |
|
| 5 | +Route::middleware([ 'check.access.to.monitoring.panel' ])->group(function() { |
|
| 6 | + Route::get('/monitoring-panel', function() { |
|
| 7 | 7 | return view('mohsenabrishami::MonitoringPanel'); |
| 8 | 8 | })->name('monitoring-panel'); |
| 9 | 9 | }); |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | use Illuminate\Support\Facades\Route; |
| 4 | 4 | use MohsenAbrishami\Stethoscope\Http\Controllers\MonitorController; |
| 5 | 5 | |
| 6 | -Route::middleware(['check.access.to.monitoring.panel'])->group(function () { |
|
| 7 | - Route::get('monitor/current', [MonitorController::class, 'current']); |
|
| 8 | - Route::get('monitor/history/{from}/{to}', [MonitorController::class, 'history']); |
|
| 6 | +Route::middleware([ 'check.access.to.monitoring.panel' ])->group(function() { |
|
| 7 | + Route::get('monitor/current', [ MonitorController::class, 'current' ]); |
|
| 8 | + Route::get('monitor/history/{from}/{to}', [ MonitorController::class, 'history' ]); |
|
| 9 | 9 | }); |
| 10 | 10 | \ No newline at end of file |
@@ -8,11 +8,13 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function handle($request, Closure $next) |
| 10 | 10 | { |
| 11 | - if (!config('stethoscope.monitoring_panel_status')) |
|
| 12 | - abort(404); |
|
| 11 | + if (!config('stethoscope.monitoring_panel_status')) { |
|
| 12 | + abort(404); |
|
| 13 | + } |
|
| 13 | 14 | |
| 14 | - if (config('stethoscope.monitoring_panel_key') && request()->get('key') != config('stethoscope.monitoring_panel_key')) |
|
| 15 | - abort(404); |
|
| 15 | + if (config('stethoscope.monitoring_panel_key') && request()->get('key') != config('stethoscope.monitoring_panel_key')) { |
|
| 16 | + abort(404); |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | return $next($request); |
| 18 | 20 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | public function register() |
| 21 | 21 | { |
| 22 | - $this->app->singleton('record', function ($app) { |
|
| 22 | + $this->app->singleton('record', function($app) { |
|
| 23 | 23 | return new LogManager($app); |
| 24 | 24 | }); |
| 25 | 25 | |
@@ -63,6 +63,6 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $this->loadViewsFrom(__DIR__ . '/../resources/views', 'mohsenabrishami'); |
| 65 | 65 | |
| 66 | - $this->app['router']->aliasMiddleware('check.access.to.monitoring.panel', CheckAccessToMonitoringPanel::class); |
|
| 66 | + $this->app[ 'router' ]->aliasMiddleware('check.access.to.monitoring.panel', CheckAccessToMonitoringPanel::class); |
|
| 67 | 67 | } |
| 68 | 68 | } |