mirror of
https://github.com/bdnugget/speedtest-tracker.git
synced 2026-11-07 08:37:27 +00:00
Added public dashboard enabled setting to general settings (#856)
This commit is contained in:
1 parent
91a4547a3b
commit
22ae7022a6
4 files changed
+31
No files matched your search
@@ -114,6 +114,18 @@ class GeneralPage extends SettingsPage
|
||||
'default' => 1,
|
||||
'md' => 2,
|
||||
]),
|
||||
|
||||
Forms\Components\Section::make('Public Dashboard Settings')
|
||||
->schema([
|
||||
Forms\Components\Toggle::make('public_dashboard_enabled')
|
||||
->label('Enable')
|
||||
->columnSpan(2),
|
||||
])
|
||||
->compact()
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'md' => 2,
|
||||
]),
|
||||
])
|
||||
->columnSpan('full'),
|
||||
]);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Result;
|
||||
use App\Settings\GeneralSettings;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
@@ -12,6 +13,11 @@ class HomeController extends Controller
|
||||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
$settings = new GeneralSettings();
|
||||
if (!$settings->public_dashboard_enabled) {
|
||||
return redirect()->route('filament.admin.auth.login');
|
||||
}
|
||||
|
||||
$latestResult = Result::query()
|
||||
->select(['id', 'ping', 'download', 'upload', 'successful', 'created_at'])
|
||||
->latest()
|
||||
|
||||
@@ -19,6 +19,8 @@ class GeneralSettings extends Settings
|
||||
|
||||
public string $timezone;
|
||||
|
||||
public bool $public_dashboard_enabled;
|
||||
|
||||
public static function group(): string
|
||||
{
|
||||
return 'general';
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Spatie\LaravelSettings\Migrations\SettingsMigration;
|
||||
|
||||
return new class extends SettingsMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->migrator->add('general.public_dashboard_enabled', true);
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user