From 57f46c6dcba196e044e174c00185e14859925bd8 Mon Sep 17 00:00:00 2001 From: sirzento Date: Fri, 16 May 2025 10:49:05 +0200 Subject: [PATCH] Added alert() to BlueprintExtensionLibrary --- .../ExtensionLibrary/BlueprintBaseLibrary.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/BlueprintFramework/Libraries/ExtensionLibrary/BlueprintBaseLibrary.php b/app/BlueprintFramework/Libraries/ExtensionLibrary/BlueprintBaseLibrary.php index 6ff693d..453c78b 100644 --- a/app/BlueprintFramework/Libraries/ExtensionLibrary/BlueprintBaseLibrary.php +++ b/app/BlueprintFramework/Libraries/ExtensionLibrary/BlueprintBaseLibrary.php @@ -17,6 +17,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Collection; use Symfony\Component\Yaml\Yaml; +use Alert; class BlueprintBaseLibrary { @@ -289,4 +290,31 @@ public function extensionsConfigs(): Collection return $collection; } + + /** + * Displays an alert message at the top of the page. + * + * @param 'info'|'warning'|'danger'|'success' $type The type of alert. + * @param string $message Alert message. + * + * [BlueprintExtensionLibrary documentation](https://blueprint.zip/docs/?page=documentation/$blueprint) + */ + public function alert(string $type, string $message): void + { + switch ($type) { + case 'success': + Alert::success($message)->flash(); + break; + case 'warning': + Alert::warning($message)->flash(); + break; + case 'danger': + Alert::danger($message)->flash(); + break; + case 'info': + default: + Alert::info($message)->flash(); + break; + } + } }