From 521f9c884c5bc4bbde525e2d247a3efbaf50270a Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 19 Jan 2026 17:32:44 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=99=20=20More=20fixes=20=F0=9F=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/Actions/Fortify/CreateNewUser.php | 18 +++++++++++------- Updated_Cms/app/Observers/UserObserver.php | 1 - .../app/Services/PermissionsService.php | 14 +++++++------- Updated_Cms/app/Services/RconService.php | 18 ++++++++++++++---- Updated_Cms/app/Services/SettingsService.php | 18 +++++++++++------- ...0_add_two_factor_columns_to_users_table.php | 7 +++---- 6 files changed, 46 insertions(+), 30 deletions(-) diff --git a/Updated_Cms/app/Actions/Fortify/CreateNewUser.php b/Updated_Cms/app/Actions/Fortify/CreateNewUser.php index 2fd1909ad1..a45e928dc2 100644 --- a/Updated_Cms/app/Actions/Fortify/CreateNewUser.php +++ b/Updated_Cms/app/Actions/Fortify/CreateNewUser.php @@ -67,6 +67,7 @@ class CreateNewUser implements CreatesNewUsers 'ip_current' => $ip, 'auth_ticket' => '', 'home_room' => (int) (setting('hotel_home_room') ?: 0), + 'referral_code' => '', ]); $user->update([ @@ -134,17 +135,20 @@ class CreateNewUser implements CreatesNewUsers private function sendDiscordWebhook(string $username, string $ip, string $email): void { if (setting('discord_webhook_url') === '') { - Log::error('Discord webhook url not provided', ['Please provide a discord webhook url before being able to send any webhook requests.']); - + Log::error('Discord webhook url not provided', [ + 'message' => 'Please provide a discord webhook url before being able to send any webhook requests.', + ]); return; } - $request = Http::asJson()->post(setting('discord_webhook_url'), [ - 'username' => sprintf('%s Bot', setting('hotel_name')), - 'content' => "User: {$username} has just registered, with the IP: {$ip} and E-mail: {$email}", - ]); + $request = Http::asJson()->post( + url: setting('discord_webhook_url'), + data: [ + 'username' => sprintf('%s Bot', setting('hotel_name')), + 'content' => "User: {$username} has just registered, with the IP: {$ip} and E-mail: {$email}", + ] + ); - // Log the error in-case webhook wasn't sent if (! $request->successful()) { Log::error('Failed to send Discord webhook notification', [ 'username' => $username, diff --git a/Updated_Cms/app/Observers/UserObserver.php b/Updated_Cms/app/Observers/UserObserver.php index b1d7de948f..81cdb53cdc 100644 --- a/Updated_Cms/app/Observers/UserObserver.php +++ b/Updated_Cms/app/Observers/UserObserver.php @@ -8,7 +8,6 @@ class UserObserver { public function created(User $user): void { - // We voegen haakjes toe zodat PHP 8.5 de volgorde begrijpt $isHcEnabled = (setting('give_hc_on_register') ?: '0') === '1'; $user->settings()->create([ diff --git a/Updated_Cms/app/Services/PermissionsService.php b/Updated_Cms/app/Services/PermissionsService.php index 6b597022d5..9248e2b911 100644 --- a/Updated_Cms/app/Services/PermissionsService.php +++ b/Updated_Cms/app/Services/PermissionsService.php @@ -8,14 +8,14 @@ use Illuminate\Support\Facades\Cache; class PermissionsService { - public ?Collection $permissions; + public private(set) ?Collection $permissions; public function __construct() { $this->permissions = Cache::remember( - 'website_permissions', - now()->addMinutes(30), - fn () => WebsitePermission::all()->pluck('min_rank', 'permission') + key: 'website_permissions', + ttl: now()->addMinutes(30), + callback: fn () => WebsitePermission::all()->pluck('min_rank', 'permission') ); } @@ -37,9 +37,9 @@ class PermissionsService Cache::forget('website_permissions'); $this->permissions = Cache::remember( - 'website_permissions', - now()->addMinutes(30), - fn () => WebsitePermission::all()->pluck('min_rank', 'permission') + key: 'website_permissions', + ttl: now()->addMinutes(30), + callback: fn () => WebsitePermission::all()->pluck('min_rank', 'permission') ); } } diff --git a/Updated_Cms/app/Services/RconService.php b/Updated_Cms/app/Services/RconService.php index d23070f847..63b3db8530 100644 --- a/Updated_Cms/app/Services/RconService.php +++ b/Updated_Cms/app/Services/RconService.php @@ -12,7 +12,7 @@ class RconService { protected ?Socket $socket = null; - public bool $isConnected = false; + public private(set) bool $isConnected = false; protected array $config = []; @@ -28,7 +28,7 @@ class RconService private function initialize(): void { - $this->socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + $this->socket = @socket_create(domain: AF_INET, type: SOCK_STREAM, protocol: SOL_TCP); if (! $this->socket) { $error = socket_strerror(socket_last_error()); @@ -39,8 +39,18 @@ class RconService return; } - socket_set_option($this->socket, SOL_SOCKET, SO_RCVTIMEO, ['sec' => 5, 'usec' => 0]); - socket_set_option($this->socket, SOL_SOCKET, SO_SNDTIMEO, ['sec' => 5, 'usec' => 0]); + socket_set_option( + socket: $this->socket, + level: SOL_SOCKET, + option: SO_RCVTIMEO, + value: ['sec' => 5, 'usec' => 0] + ); + socket_set_option( + socket: $this->socket, + level: SOL_SOCKET, + option: SO_SNDTIMEO, + value: ['sec' => 5, 'usec' => 0] + ); if (! @socket_connect($this->socket, $this->config['ip'], $this->config['port'])) { $error = socket_strerror(socket_last_error()); diff --git a/Updated_Cms/app/Services/SettingsService.php b/Updated_Cms/app/Services/SettingsService.php index 6133e9911e..8534d2a33c 100644 --- a/Updated_Cms/app/Services/SettingsService.php +++ b/Updated_Cms/app/Services/SettingsService.php @@ -10,15 +10,17 @@ use Throwable; class SettingsService { - public ?Collection $settings; + public private(set) ?Collection $settings; public function __construct() { try { $this->settings = Cache::remember( - 'website_settings', - now()->addMinutes(5), - fn () => Schema::hasTable('website_settings') ? WebsiteSetting::all()->pluck('value', 'key') : collect() + key: 'website_settings', + ttl: now()->addMinutes(5), + callback: fn () => Schema::hasTable('website_settings') + ? WebsiteSetting::all()->pluck('value', 'key') + : collect() ); } catch (Throwable) { $this->settings = collect(); @@ -40,9 +42,11 @@ class SettingsService try { $this->settings = Cache::remember( - 'website_settings', - now()->addMinutes(5), - fn () => Schema::hasTable('website_settings') ? WebsiteSetting::all()->pluck('value', 'key') : collect() + key: 'website_settings', + ttl: now()->addMinutes(5), + callback: fn () => Schema::hasTable('website_settings') + ? WebsiteSetting::all()->pluck('value', 'key') + : collect() ); } catch (Throwable) { $this->settings = collect(); diff --git a/Updated_Cms/database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php b/Updated_Cms/database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php index 9d31dacfe7..cc2ae17c9f 100644 --- a/Updated_Cms/database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php +++ b/Updated_Cms/database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php @@ -47,12 +47,11 @@ return new class extends Migration public function down(): void { Schema::table('users', function (Blueprint $table) { - $table->dropColumn(array_merge([ + $table->dropColumn([ 'two_factor_secret', 'two_factor_recovery_codes', - ], Fortify::confirmsTwoFactorAuthentication() ? [ - 'two_factor_confirmed_at', - ] : [])); + ...(Fortify::confirmsTwoFactorAuthentication() ? ['two_factor_confirmed_at'] : []), + ]); }); } };