*/ public array $russianTimezones = [ 'Europe/Kaliningrad' => 'Калининград (UTC+2)', 'Europe/Moscow' => 'Москва (UTC+3)', 'Europe/Samara' => 'Самара (UTC+4)', 'Asia/Yekaterinburg' => 'Екатеринбург (UTC+5)', 'Asia/Omsk' => 'Омск (UTC+6)', 'Asia/Krasnoyarsk' => 'Красноярск (UTC+7)', 'Asia/Irkutsk' => 'Иркутск (UTC+8)', 'Asia/Yakutsk' => 'Якутск (UTC+9)', 'Asia/Vladivostok' => 'Владивосток (UTC+10)', 'Asia/Magadan' => 'Магадан (UTC+11)', 'Asia/Sakhalin' => 'Сахалин (UTC+11)', 'Asia/Kamchatka' => 'Камчатка (UTC+12)', ]; public function mount(SettingsService $settingsService): void { abort_unless(auth()->user()->isAdmin(), 403); $this->companyName = (string) $settingsService->get('company_name', 'Computer Service'); $this->timezone = (string) $settingsService->get('timezone', 'Asia/Yekaterinburg'); $this->defaultSlaHours = (int) $settingsService->get('default_sla_hours', 24); $this->maintenanceMode = (bool) $settingsService->get('maintenance_mode', false); $notifications = $settingsService->emailNotifications(); $this->notifyAssigned = (bool) ($notifications['assigned'] ?? true); $this->notifyStatusChanged = (bool) ($notifications['status_changed'] ?? true); $this->notifyCommentAdded = (bool) ($notifications['comment_added'] ?? true); $this->notifyOverdue = (bool) ($notifications['overdue'] ?? true); $this->notifySlaWarning = (bool) ($notifications['sla_warning'] ?? true); } public function save(SettingsService $settingsService): void { $this->validate([ 'companyName' => ['required', 'string', 'max:255'], 'timezone' => ['required', Rule::in(array_keys($this->russianTimezones))], 'defaultSlaHours' => ['required', 'integer', 'min:1', 'max:720'], 'maintenanceMode' => ['boolean'], 'notifyAssigned' => ['boolean'], 'notifyStatusChanged' => ['boolean'], 'notifyCommentAdded' => ['boolean'], 'notifyOverdue' => ['boolean'], 'notifySlaWarning' => ['boolean'], ]); $settingsService->set('company_name', $this->companyName, 'string'); $settingsService->set('timezone', $this->timezone, 'string'); $settingsService->set('default_sla_hours', $this->defaultSlaHours, 'integer'); $settingsService->set('maintenance_mode', $this->maintenanceMode, 'boolean'); $settingsService->set('email_notifications', [ 'assigned' => $this->notifyAssigned, 'status_changed' => $this->notifyStatusChanged, 'comment_added' => $this->notifyCommentAdded, 'overdue' => $this->notifyOverdue, 'sla_warning' => $this->notifySlaWarning, ], 'json'); session()->flash('success', 'Настройки сохранены.'); } public function render() { return view('livewire.system.settings-page')->title('Системные настройки'); } }