refactor: improve code quality across controllers and services

- DRY FurniEditorController: extract duplicate try/catch blocks into handleApiError(),
  formatItemData(), buildUpdateData(), buildInsertData(), castValue() methods
- ProfileController: replace 45 lines of manual date formatting with Carbon's diffForHumans()
- Replace custom Password rule (180 lines) with Laravel's built-in Password::min() rule
- RadioController: extract RadioStreamService and RadioScheduleService, reducing from 608 to 323 lines
- Add RadioSettings enum to replace magic strings throughout radio feature
- Add CurrencyTypes::columnName() helper method
- Add consistent return types (JsonResponse, View, RedirectResponse) to all controller methods
This commit is contained in:
root
2026-05-19 19:16:59 +02:00
parent 8567ce6951
commit 81e99933e4
9 changed files with 636 additions and 731 deletions
+10
View File
@@ -30,6 +30,16 @@ enum CurrencyTypes: int
};
}
public function columnName(): string
{
return match ($this) {
self::Credits => 'credits',
self::Duckets => 'duckets',
self::Diamonds => 'diamonds',
self::Points => 'points',
};
}
public function getImage(): string
{
return match ($this->value) {
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace App\Enums;
enum RadioSettings: string
{
case Enabled = 'radio_enabled';
case StreamUrl = 'radio_stream_url';
case CurrentDjId = 'radio_current_dj_id';
case Style = 'radio_style';
case ShoutsEnabled = 'radio_shouts_enabled';
case ApplicationsEnabled = 'radio_applications_enabled';
case NowPlayingEnabled = 'radio_now_playing_enabled';
case NowPlayingApiUrl = 'radio_now_playing_api_url';
case ListenersEnabled = 'radio_listeners_enabled';
case ListenersApiUrl = 'radio_listeners_api_url';
case AzureCastBaseUrl = 'radio_azurecast_base_url';
case AzureCastStationId = 'radio_azurecast_station_id';
case ShowCurrentDj = 'radio_show_current_dj';
case WidgetEnabled = 'radio_widget_enabled';
case WidgetShowGlobally = 'radio_widget_show_globally';
case WidgetPosition = 'radio_widget_position';
public function label(): string
{
return match ($this) {
self::Enabled => 'Radio Enabled',
self::StreamUrl => 'Stream URL',
self::CurrentDjId => 'Current DJ ID',
self::Style => 'Radio Style',
self::ShoutsEnabled => 'Shouts Enabled',
self::ApplicationsEnabled => 'Applications Enabled',
self::NowPlayingEnabled => 'Now Playing Enabled',
self::NowPlayingApiUrl => 'Now Playing API URL',
self::ListenersEnabled => 'Listeners Enabled',
self::ListenersApiUrl => 'Listeners API URL',
self::AzureCastBaseUrl => 'AzureCast Base URL',
self::AzureCastStationId => 'AzureCast Station ID',
self::ShowCurrentDj => 'Show Current DJ',
self::WidgetEnabled => 'Widget Enabled',
self::WidgetShowGlobally => 'Widget Show Globally',
self::WidgetPosition => 'Widget Position',
};
}
}