Added setting for app name

This commit is contained in:
Henry Whitaker
2020-12-19 23:55:49 +00:00
parent 46d13fd08a
commit 95325db128
4 changed files with 69 additions and 25 deletions

View File

@@ -91,6 +91,11 @@ class SettingsHelper
*/
public static function settingIsEditable(string $key)
{
// Manual override for app_name
if ($key === 'app_name') {
return true;
}
$results = [];
// Try exact key
@@ -139,6 +144,7 @@ class SettingsHelper
{
return [
'base' => SettingsHelper::getBase(),
'name' => SettingsHelper::get('app_name')->value,
'widgets' => [
'show_average' => (bool)SettingsHelper::get('show_average')->value,
'show_max' => (bool)SettingsHelper::get('show_max')->value,

View File

@@ -0,0 +1,38 @@
<?php
use App\Helpers\SettingsHelper;
use App\Setting;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAppNameSetting extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!SettingsHelper::get('app_name')) {
Setting::create([
'name' => 'app_name',
'value' => 'Speedtest Tracker',
'description' => 'Set a custom app name'
]);
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Setting::whereIn('name', [
'app_name',
])->delete();
}
}

View File

@@ -30,6 +30,6 @@ Route::get(SettingsHelper::getBase() . 'files/{path?}', function($file) {
->name('files');
Route::get('/{path?}', function () {
return view('app', [ 'title' => 'Speedtest Tracker' ]);
return view('app', ['title' => SettingsHelper::get('app_name')->value]);
})->where('path', '^((?!\/api\/).)*$')
->name('react');