2023-01-24 09:25:05 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
|
|
|
|
use Livewire\Component;
|
|
|
|
use App\Models\Setting;
|
|
|
|
|
|
|
|
class SlackSettingsForm extends Component
|
|
|
|
{
|
2023-01-25 16:22:34 -08:00
|
|
|
public $slack_endpoint;
|
|
|
|
public $slack_channel;
|
|
|
|
public $slack_botname;
|
|
|
|
|
2023-01-24 09:25:05 -08:00
|
|
|
public Setting $setting;
|
|
|
|
|
2023-01-25 14:29:20 -08:00
|
|
|
protected $rules = [
|
2023-01-25 16:22:34 -08:00
|
|
|
'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',
|
2023-01-25 14:29:20 -08:00
|
|
|
];
|
2023-01-25 16:38:08 -08:00
|
|
|
protected $messages = [
|
|
|
|
'slack_endpoint.required_with' => 'Slack endpoint is required',
|
|
|
|
'slack_endpoint.starts_with' => 'Slack endpoint must start with https://hooks.slack.com',
|
|
|
|
|
|
|
|
|
|
|
|
];
|
2023-01-24 09:25:05 -08:00
|
|
|
|
2023-01-25 16:22:34 -08:00
|
|
|
public function mount(){
|
|
|
|
|
2023-01-25 16:38:08 -08:00
|
|
|
$this->setting = Setting::getSettings();
|
2023-01-25 16:22:34 -08:00
|
|
|
$this->slack_endpoint = $this->setting->slack_endpoint;
|
|
|
|
$this->slack_channel = $this->setting->slack_channel;
|
|
|
|
$this->slack_botname = $this->setting->slack_botname;
|
|
|
|
|
|
|
|
}
|
2023-01-24 09:25:05 -08:00
|
|
|
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.slack-settings-form');
|
|
|
|
}
|
|
|
|
|
2023-01-25 16:22:34 -08:00
|
|
|
public function submit()
|
|
|
|
{
|
2023-01-26 15:17:08 -08:00
|
|
|
dd("we here now");
|
2023-01-25 16:22:34 -08:00
|
|
|
|
|
|
|
$this->validate();
|
|
|
|
|
|
|
|
$this->setting->slack_endpoint = $this->slack_endpoint;
|
|
|
|
$this->setting->slack_channel = $this->slack_channel;
|
|
|
|
$this->setting->slack_botname = $this->slack_botname;
|
|
|
|
|
|
|
|
}
|
2023-01-24 09:25:05 -08:00
|
|
|
}
|