A free open source IT asset/license management system
adds validation to the update hook, removes typos and deadlines
Godfrey M74c64c1fc5a3
diff --git a/app/Http/Livewire/SlackSettingsForm.php b/app/Http/Livewire/SlackSettingsForm.phpindex 9e83087112..8e3e148f3d 100644--- a/app/Http/Livewire/SlackSettingsForm.php+++ b/app/Http/Livewire/SlackSettingsForm.php@@ -14,6 +14,12 @@ class SlackSettingsForm extends Componentpublic 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 Componentpublic 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.phpindex 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 @@</div><div class="col-md-10">@if (config('app.lock_passwords')===true)-{{-- {{ Form::text('slack_endpoint', old('slack_endpoint', $setting->slack_endpoint), array('class' => 'form-control','disabled'=>'disabled','placeholder' => 'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX', 'id' => 'slack_endpoint')) }}--}}<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>- <input type="text" wire:model.lazy="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX'" {{old('slack_endpoint', $slack_endpoint)}} ><br>+ <input type="text" wire:model.lazy="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX" {{old('slack_endpoint', $slack_endpoint)}} ><br>@else- <input type="text" wire:model.lazy="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX'" {{old('slack_endpoint', $slack_endpoint)}} ><br>-{{-- {{ Form::text('slack_endpoint', old('slack_endpoint', $setting->slack_endpoint), array('class' => 'form-control','placeholder' => 'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX', 'id' => 'slack_endpoint')) }}--}}+ <input type="text" wire:model.lazy="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX" {{old('slack_endpoint', $slack_endpoint)}} ><br>@endif{!! $errors->first('slack_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}</div>@@ -66,12 +64,11 @@</div><div class="col-md-10">@if (config('app.lock_passwords')===true)-{{-- {{ Form::text('slack_botname', old('slack_botname', $setting->slack_botname), array('class' => 'form-control','disabled'=>'disabled','placeholder' => 'Snipe-Bot')) }}--}}- <input type="text" wire:model.lazy="slack_botname" id="slack_botname" class= 'form-control' placeholder="'Snipe-Bot'" {{old('slack_botname', $slack_botname)}} ><br>+ <input type="text" wire:model.lazy="slack_botname" id="slack_botname" class= 'form-control' placeholder="Snipe-Bot" {{old('slack_botname', $slack_botname)}} ><br><p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>@else- <input type="text" wire:model.lazy="slack_botname" id="slack_botname" class= 'form-control' placeholder="'Snipe-Bot'" {{old('slack_botname', $slack_botname)}} ><br>+ <input type="text" wire:model.lazy="slack_botname" id="slack_botname" class= 'form-control' placeholder="Snipe-Bot" {{old('slack_botname', $slack_botname)}} ><br>@endif{!! $errors->first('slack_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}</div><!--col-md-10-->