opnform/app/Models/Integration/FormZapierWebhook.php

41 lines
844 B
PHP
Raw Permalink Normal View History

2022-09-20 19:59:52 +00:00
<?php
namespace App\Models\Integration;
use App\Models\Forms\Form;
use App\Service\Forms\Webhooks\WebhookHandlerProvider;
2022-09-20 19:59:52 +00:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class FormZapierWebhook extends Model
{
2024-02-23 10:54:12 +00:00
use HasFactory;
use SoftDeletes;
2022-09-20 19:59:52 +00:00
protected $table = 'form_zapier_webhooks';
protected $fillable = [
'form_id',
'hook_url',
];
/**
* Relationships
*/
public function form()
{
return $this->belongsTo(Form::class);
}
2024-02-23 10:54:12 +00:00
public function triggerHook(array $data)
{
WebhookHandlerProvider::getProvider(
$this->form,
$data,
WebhookHandlerProvider::ZAPIER_PROVIDER,
$this->hook_url
)->handle();
2022-09-20 19:59:52 +00:00
}
}