PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.40
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.40
2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 1.45 All 41 releases
fluent-boards / app / Http / Controllers / WebhookController.php

WebhookController.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.40, at app/Http/Controllers/WebhookController.php

83 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\App\Http\Controllers;
4
5 use FluentBoards\App\Models\Webhook;
6 use FluentBoards\Framework\Http\Request\Request;
7
8
9 class WebhookController extends Controller
10 {
11 public function index(Request $request, Webhook $webhook)
12 {
13 $fields = $webhook->getFields();
14 $search = $request->getSafe('search', '');
15
16 $webhooks = $webhook->latest()->get()->toArray();
17
18 if ( ! empty($search)) {
19 $search = strtolower($search);
20 $webhooks = array_map(function ($row) use ($search) {
21 $name = strtolower($row['value']['name']);
22 if ($row['value'] && str_contains($name, $search)) {
23 return $row;
24 }
25
26 return null;
27 }, $webhooks);
28 }
29
30 $rows = [];
31 foreach ($webhooks as $row) {
32 if ($row) {
33 $rows[] = $row;
34 }
35 }
36
37
38 $response = [
39 'webhooks' => $rows,
40 'fields' => $fields['fields']
41 ];
42
43 return $response;
44 }
45
46 public function create(Request $request, Webhook $webhook)
47 {
48 $webhook = $webhook->store(
49 $this->validate(
50 $request->all(),
51 ['name' => 'required']
52 )
53 );
54
55 return [
56 'id' => $webhook->id,
57 'webhook' => $webhook->value,
58 'webhooks' => $webhook->latest()->get(),
59 'message' => __('Successfully Created the WebHook', 'fluent-boards'),
60 ];
61 }
62
63 public function update(Request $request, Webhook $webhook, $id)
64 {
65 $webhook->find($id)->saveChanges($request->all());
66
67 return [
68 'webhooks' => $webhook->latest()->get(),
69 'message' => __('Successfully updated the webhook', 'fluent-boards'),
70 ];
71 }
72
73 public function delete(Webhook $webhook, $id)
74 {
75 $webhook->where('id', $id)->delete();
76
77 return [
78 'webhooks' => $webhook->latest()->get(),
79 'message' => __('Successfully deleted the webhook', 'fluent-boards'),
80 ];
81 }
82 }
83