2022-09-20 19:59:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Integration;
|
|
|
|
|
|
|
|
use App\Models\Forms\Form;
|
|
|
|
use App\Models\Integration\FormZapierWebhook;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
class StoreFormZapierWebhookRequest extends FormRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'form_slug' => 'required|exists:forms,slug',
|
2024-02-23 10:54:12 +00:00
|
|
|
'hook_url' => 'required|string|url',
|
2022-09-20 19:59:52 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-02-23 10:54:12 +00:00
|
|
|
public function instanciateHook()
|
|
|
|
{
|
2022-09-20 19:59:52 +00:00
|
|
|
$form = Form::whereSlug($this->form_slug)->firstOrFail();
|
2024-02-23 10:54:12 +00:00
|
|
|
|
2022-09-20 19:59:52 +00:00
|
|
|
return new FormZapierWebhook([
|
|
|
|
'form_id' => $form->id,
|
|
|
|
'hook_url' => $this->hook_url,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|