Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/Events/SpeedtestCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ class SpeedtestCompleted
*/
public function __construct(
public Result $result,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions app/Events/SpeedtestFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ class SpeedtestFailed
*/
public function __construct(
public Result $result,
) {
}
) {}
}
3 changes: 1 addition & 2 deletions app/Events/SpeedtestStarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ class SpeedtestStarted
*/
public function __construct(
public Result $result,
) {
}
) {}
}
4 changes: 0 additions & 4 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class HomeController extends Controller
*/
public function __invoke(Request $request)
{
if (! config('speedtest.public_dashboard')) {
return redirect()->route('filament.admin.auth.login');
}

$latestResult = Result::query()
->select(['id', 'ping', 'download', 'upload', 'status', 'created_at'])
->where('status', '=', ResultStatus::Completed)
Expand Down
24 changes: 24 additions & 0 deletions app/Http/Middleware/PublicDashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class PublicDashboard
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if (! config('speedtest.public_dashboard')) {
return redirect()->route('filament.admin.auth.login');
}

return $next($request);
}
}
3 changes: 1 addition & 2 deletions app/Jobs/InfluxDBv2/WriteCompletedSpeedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class WriteCompletedSpeedtest implements ShouldQueue
public function __construct(
public Result $result,
public InfluxDbSettings $settings,
) {
}
) {}

/**
* Execute the job.
Expand Down
3 changes: 1 addition & 2 deletions app/Jobs/Speedtests/ExecuteOoklaSpeedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class ExecuteOoklaSpeedtest implements ShouldBeUnique, ShouldQueue
public function __construct(
public Result $result,
public ?int $serverId,
) {
}
) {}

/**
* Execute the job.
Expand Down
3 changes: 1 addition & 2 deletions app/Jobs/TruncateResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class TruncateResults implements ShouldQueue

public function __construct(
public User $user,
) {
}
) {}

/**
* Execute the job.
Expand Down
3 changes: 1 addition & 2 deletions app/Mail/SpeedtestCompletedMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class SpeedtestCompletedMail extends Mailable implements ShouldQueue
*/
public function __construct(
public Result $result,
) {
}
) {}

/**
* Get the message envelope.
Expand Down
3 changes: 1 addition & 2 deletions app/Mail/SpeedtestThresholdMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class SpeedtestThresholdMail extends Mailable implements ShouldQueue
public function __construct(
public Result $result,
public array $metrics,
) {
}
) {}

/**
* Get the message envelope.
Expand Down
3 changes: 1 addition & 2 deletions app/Notifications/Telegram/SpeedtestNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class SpeedtestNotification extends Notification implements ShouldQueue
public function __construct(
public string $content,
public bool $disableNotification = false,
) {
}
) {}

/**
* Get the notification's delivery channels.
Expand Down
5 changes: 5 additions & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use App\Http\Middleware\PublicDashboard;
use App\Providers\AppServiceProvider;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
Expand All @@ -14,6 +15,10 @@
commands: __DIR__.'/../routes/console.php',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->alias([
'public-dashboard' => PublicDashboard::class,
]);

$middleware->redirectGuestsTo(fn () => route('admin/login'));
$middleware->redirectUsersTo(AppServiceProvider::HOME);

Expand Down
3 changes: 2 additions & 1 deletion pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"config"
],
"rules": {
"fully_qualified_strict_types": false
"fully_qualified_strict_types": false,
"single_line_empty_body": true
}
}
6 changes: 4 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
|
*/

Route::get('/', HomeController::class)
->name('home');
Route::middleware('public-dashboard')->group(function () {
Route::get('/', HomeController::class)
->name('home');
});

Route::redirect('/login', '/admin/login')
->name('login');
Expand Down