2022-09-20 21:59:52 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Forms\Integration;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Http\Requests\Integration\StoreFormZapierWebhookRequest;
|
|
|
|
|
use App\Models\Integration\FormZapierWebhook;
|
|
|
|
|
|
|
|
|
|
class FormZapierWebhookController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Controller for Zappier webhook subscriptions.
|
|
|
|
|
*/
|
2024-02-23 11:54:12 +01:00
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
// $this->middleware('subscribed');
|
2022-09-20 21:59:52 +02:00
|
|
|
$this->middleware('auth');
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-23 11:54:12 +01:00
|
|
|
public function store(StoreFormZapierWebhookRequest $request)
|
|
|
|
|
{
|
2022-09-20 21:59:52 +02:00
|
|
|
$hook = $request->instanciateHook();
|
|
|
|
|
$this->authorize('store', $hook);
|
|
|
|
|
|
|
|
|
|
$hook->save();
|
2024-02-23 11:54:12 +01:00
|
|
|
|
2022-09-20 21:59:52 +02:00
|
|
|
return $this->success([
|
|
|
|
|
'message' => 'Webhook created.',
|
2024-02-23 11:54:12 +01:00
|
|
|
'hook' => $hook,
|
2022-09-20 21:59:52 +02:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-23 11:54:12 +01:00
|
|
|
public function delete($id)
|
|
|
|
|
{
|
2022-09-20 21:59:52 +02:00
|
|
|
$hook = FormZapierWebhook::findOrFail($id);
|
|
|
|
|
$this->authorize('store', $hook);
|
|
|
|
|
|
|
|
|
|
$hook->delete();
|
2024-02-23 11:54:12 +01:00
|
|
|
|
2022-09-20 21:59:52 +02:00
|
|
|
return $this->success([
|
|
|
|
|
'message' => 'Webhook deleted.',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|