From 725f49050119acf8b43363cb73b4c07e731abc7f Mon Sep 17 00:00:00 2001 From: WINBIGFOX Date: Tue, 18 Mar 2025 23:16:07 +0100 Subject: [PATCH 1/2] feat: implement Alert class and facade for alert management --- src/Alert.php | 108 ++++++++++++++++++++++++++++++++++++++++++ src/Facades/Alert.php | 23 +++++++++ 2 files changed, 131 insertions(+) create mode 100644 src/Alert.php create mode 100644 src/Facades/Alert.php diff --git a/src/Alert.php b/src/Alert.php new file mode 100644 index 0000000..625010b --- /dev/null +++ b/src/Alert.php @@ -0,0 +1,108 @@ +type = $type; + + return $this; + } + + public function title(string $title): self + { + $this->title = $title; + + return $this; + } + + public function detail(string $detail): self + { + $this->detail = $detail; + + return $this; + } + + public function buttons(array $buttons): self + { + $this->buttons = $buttons; + + return $this; + } + + public function defaultPath(string $defaultPath): self + { + $this->defaultPath = $defaultPath; + + return $this; + } + + public function button(string $buttonLabel): self + { + $this->buttonLabel = $buttonLabel; + + return $this; + } + + public function defaultId(int $defaultId): self + { + $this->defaultId = $defaultId; + + return $this; + } + + public function cancelId(int $cancelId): self + { + $this->cancelId = $cancelId; + + return $this; + } + + public function show(string $message): int + { + $response = $this->client->post('alert/message', [ + 'message' => $message, + 'type' => $this->type, + 'title' => $this->title, + 'detail' => $this->detail, + 'buttons' => $this->buttons, + 'defaultId' => $this->defaultId, + 'cancelId' => $this->cancelId + ]); + + return (int) $response->json('result'); + } + + public function error(string $title, string $message): bool + { + $response = $this->client->post('alert/error', [ + 'title' => $title, + 'message' => $message, + ]); + + return (bool) $response->json('result'); + } +} diff --git a/src/Facades/Alert.php b/src/Facades/Alert.php new file mode 100644 index 0000000..a4b151f --- /dev/null +++ b/src/Facades/Alert.php @@ -0,0 +1,23 @@ + Date: Tue, 18 Mar 2025 23:22:27 +0100 Subject: [PATCH 2/2] refactor: remove unused methods from Alert class --- src/Alert.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/Alert.php b/src/Alert.php index 625010b..4ddcb8f 100644 --- a/src/Alert.php +++ b/src/Alert.php @@ -53,20 +53,6 @@ public function buttons(array $buttons): self return $this; } - public function defaultPath(string $defaultPath): self - { - $this->defaultPath = $defaultPath; - - return $this; - } - - public function button(string $buttonLabel): self - { - $this->buttonLabel = $buttonLabel; - - return $this; - } - public function defaultId(int $defaultId): self { $this->defaultId = $defaultId;