diff --git a/app/Livewire/Settings/Synapse.php b/app/Livewire/Settings/Synapse.php new file mode 100644 index 0000000..a481e62 --- /dev/null +++ b/app/Livewire/Settings/Synapse.php @@ -0,0 +1,33 @@ +synapseEndpoint = Settings::get('synapse_endpoint', ''); + $this->synapseAccessToken = Settings::get('synapse_access_token', ''); + } + + public function save(): void + { + Settings::set('synapse_endpoint', $this->synapseEndpoint); + Settings::set('synapse_access_token', $this->synapseAccessToken); + } + + public function render() + { + return view('livewire.settings.synapse'); + } +} diff --git a/app/Models/Settings.php b/app/Models/Settings.php new file mode 100644 index 0000000..da42806 --- /dev/null +++ b/app/Models/Settings.php @@ -0,0 +1,23 @@ +value('value') ?? $default; + } + + public static function set($key, $value) + { + return static::updateOrCreate(['key' => $key], ['value' => $value]); + } +} diff --git a/app/Services/SynapseService.php b/app/Services/SynapseService.php index 0dde34b..c15bdf7 100644 --- a/app/Services/SynapseService.php +++ b/app/Services/SynapseService.php @@ -2,6 +2,8 @@ namespace App\Services; +use App\Models\Settings; + use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; @@ -9,8 +11,8 @@ class SynapseService { public function createRegistrationToken(): ?string { - $token = config('synapse.admin_api_token'); - $endpoint = config('synapse.admin_api_url'); + $token = Settings::get('synapse_access_token', ''); + $endpoint = Settings::get('synapse_endpoint', ''); $response = Http::withHeaders([ 'Authorization' => "Bearer $token", diff --git a/config/synapse.php b/config/synapse.php deleted file mode 100644 index fd4ba6b..0000000 --- a/config/synapse.php +++ /dev/null @@ -1,27 +0,0 @@ - env('SYNAPSE_ADMIN_API_TOKEN'), - - /* - |-------------------------------------------------------------------------- - | Admin API Endpoint - |-------------------------------------------------------------------------- - | - | This variable contains the admin endpoint for synapse. - | - */ - - 'admin_api_url' => env('SYNAPSE_ADMIN_API_URL'), - -]; diff --git a/database/migrations/2025_05_03_092111_create_settings_table.php b/database/migrations/2025_05_03_092111_create_settings_table.php new file mode 100644 index 0000000..2ae121f --- /dev/null +++ b/database/migrations/2025_05_03_092111_create_settings_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('key')->unique(); + $table->string('value'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('settings'); + } +}; diff --git a/resources/views/components/layouts/app/sidebar.blade.php b/resources/views/components/layouts/app/sidebar.blade.php index 781550e..4583fb8 100644 --- a/resources/views/components/layouts/app/sidebar.blade.php +++ b/resources/views/components/layouts/app/sidebar.blade.php @@ -10,6 +10,7 @@ {{ __('Applications') }} + {{ __('Synapse') }} diff --git a/resources/views/livewire/settings/synapse.blade.php b/resources/views/livewire/settings/synapse.blade.php new file mode 100644 index 0000000..e3e5303 --- /dev/null +++ b/resources/views/livewire/settings/synapse.blade.php @@ -0,0 +1,21 @@ +
+ +
+
+ {{ __('Settings') }} + {{ __('Manage synapse endpoint and access token') }} + + +
+ +
+ + + + + Save +
+
+
diff --git a/routes/web.php b/routes/web.php index bfe22e7..d456f0c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,6 +3,7 @@ use App\Livewire\Settings\Appearance; use App\Livewire\Settings\Password; use App\Livewire\Settings\Profile; +use App\Livewire\Settings\Synapse; use Illuminate\Support\Facades\Route; Route::get('/', App\Livewire\ApplicationForm::class)->name('home'); @@ -18,6 +19,7 @@ Route::middleware(['auth'])->group(function () { Route::get('settings/profile', Profile::class)->name('settings.profile'); Route::get('settings/password', Password::class)->name('settings.password'); Route::get('settings/appearance', Appearance::class)->name('settings.appearance'); + Route::get('settings/synapse', Synapse::class)->name('settings.synapse'); }); require __DIR__ . '/auth.php';