diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.php index 9e83087112..8e3e148f3d 100644 --- a/app/Http/Livewire/SlackSettingsForm.php +++ b/app/Http/Livewire/SlackSettingsForm.php @@ -14,6 +14,12 @@ class SlackSettingsForm extends Component public Setting $setting; + protected $rules = [ + 'slack_endpoint' => 'url|required_with:slack_channel|starts_with:https://hooks.slack.com/|nullable', + 'slack_channel' => 'required_with:slack_endpoint|starts_with:#|nullable', + 'slack_botname' => 'string|nullable', + ]; + public function mount(){ $this->setting = Setting::getSettings(); @@ -22,6 +28,10 @@ class SlackSettingsForm extends Component $this->slack_botname = $this->setting->slack_botname; } + public function updated($field){ + + $this->validateOnly($field ,$this->rules); + } public function render() { @@ -30,7 +40,6 @@ class SlackSettingsForm extends Component public function testSlack(){ - // If validation passes, continue to the curl request $slack = new Client([ 'base_url' => e($this->slack_endpoint), 'defaults' => [ @@ -62,11 +71,7 @@ class SlackSettingsForm extends Component } public function submit() { - $this->validate([ - 'slack_endpoint' => 'url|required_with:slack_channel|starts_with:https://hooks.slack.com/|nullable', - 'slack_channel' => 'required_with:slack_endpoint|starts_with:#|nullable', - 'slack_botname' => 'string|nullable', - ]); + $this->validate($this->rules); $this->setting->slack_endpoint = $this->slack_endpoint; $this->setting->slack_channel = $this->slack_channel; diff --git a/resources/views/livewire/slack-settings-form.blade.php b/resources/views/livewire/slack-settings-form.blade.php index 0335b6d0cc..c165118cbd 100644 --- a/resources/views/livewire/slack-settings-form.blade.php +++ b/resources/views/livewire/slack-settings-form.blade.php @@ -31,12 +31,10 @@
{{ trans('general.feature_disabled') }}
-{{ trans('general.feature_disabled') }}
@else -