mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-21 13:23:04 +01:00
Added settings section and custom cron scheduling
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\SettingsHelper;
|
||||
use App\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@@ -17,12 +18,31 @@ class CreateSettingsTable extends Migration
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->unique();
|
||||
$table->string('description')->nullable();
|
||||
$table->string('value');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
SettingsHelper::set('schedule', '0 * * * *');
|
||||
SettingsHelper::set('server', '');
|
||||
$settings = [
|
||||
[
|
||||
'name' => 'schedule',
|
||||
'value' => '0 * * * *',
|
||||
'description' => '<p class="d-inline">Set the schedule for speedtests to run using the CRON format. </p><a href="https://crontab.guru/" target="_blank" rel="noopener noreferer">This site</a> can help with formatting.'
|
||||
],
|
||||
[
|
||||
'name' => 'server',
|
||||
'value' => '',
|
||||
'description' => '<p class="d-inline">Comma-separated list of speedtest.net servers picked randomly. Leave blank to use default settings.</p>'
|
||||
]
|
||||
];
|
||||
|
||||
foreach($settings as $s) {
|
||||
Setting::create([
|
||||
'name' => $s['name'],
|
||||
'value' => $s['value'],
|
||||
'description' => $s['description']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user