Added settings section and custom cron scheduling

This commit is contained in:
Henry Whitaker
2020-05-19 01:08:35 +01:00
parent e889a4f487
commit 2a5fd76c42
14 changed files with 288 additions and 11 deletions

View File

@@ -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']
]);
}
}
/**