3 namespace BookStack\Http\Controllers;
5 use BookStack\Actions\ActivityType;
6 use BookStack\Actions\Webhook;
7 use Illuminate\Http\Request;
9 class WebhookController extends Controller
11 public function __construct()
14 'can:settings-manage',
19 * Show all webhooks configured in the system.
21 public function index()
23 // TODO - Get and pass webhooks
24 return view('settings.webhooks.index');
28 * Show the view for creating a new webhook in the system.
30 public function create()
32 return view('settings.webhooks.create');
36 * Store a new webhook in the system.
38 public function store(Request $request)
40 // TODO - Create webhook
41 $this->logActivity(ActivityType::WEBHOOK_CREATE, $webhook);
42 return redirect('/settings/webhooks');
46 * Show the view to edit an existing webhook.
48 public function edit(string $id)
50 /** @var Webhook $webhook */
51 $webhook = Webhook::query()->findOrFail($id);
53 return view('settings.webhooks.edit', ['webhook' => $webhook]);
57 * Update an existing webhook with the provided request data.
59 public function update(Request $request, string $id)
61 /** @var Webhook $webhook */
62 $webhook = Webhook::query()->findOrFail($id);
66 $this->logActivity(ActivityType::WEBHOOK_UPDATE, $webhook);
67 return redirect('/settings/webhooks');
71 * Show the view to delete a webhook.
73 public function delete(string $id)
75 /** @var Webhook $webhook */
76 $webhook = Webhook::query()->findOrFail($id);
77 return view('settings.webhooks.delete', ['webhook' => $webhook]);
81 * Destroy a webhook from the system.
83 public function destroy(string $id)
85 /** @var Webhook $webhook */
86 $webhook = Webhook::query()->findOrFail($id);
88 // TODO - Delete event type relations
91 $this->logActivity(ActivityType::WEBHOOK_DELETE, $webhook);
92 return redirect('/settings/webhooks');