From 2123bf34cf624e5fbb930e74b556772b60d917f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Thu, 18 May 2023 14:23:21 +0300 Subject: [PATCH] Added new blade directive `moduleIsEnabled` and `module_is_enabled` helper function. --- app/Providers/Blade.php | 4 ++++ app/Utilities/helpers.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/app/Providers/Blade.php b/app/Providers/Blade.php index 1edb0ecde..b7a5db9da 100644 --- a/app/Providers/Blade.php +++ b/app/Providers/Blade.php @@ -29,6 +29,10 @@ class Blade extends ServiceProvider return ""; }); + Facade::directive('moduleIsEnabled', function ($expression) { + return ""; + }); + Facade::if('readonly', function () { return config('read-only.enabled'); }); diff --git a/app/Utilities/helpers.php b/app/Utilities/helpers.php index fbb8f8bde..8d1e995a0 100644 --- a/app/Utilities/helpers.php +++ b/app/Utilities/helpers.php @@ -3,6 +3,7 @@ use App\Models\Common\Company; use App\Traits\DateTime; use App\Traits\Sources; +use App\Traits\Modules; use App\Utilities\Date; use App\Utilities\Widgets; @@ -88,6 +89,20 @@ if (! function_exists('company')) { } } +if (! function_exists('module_is_enabled')) { + /** + * Check if a module is enabled. + */ + function module_is_enabled(string $alias): bool + { + $module = new class() { + use Modules; + }; + + return $module->moduleIsEnabled($alias); + } +} + if (! function_exists('company_id')) { /** * Get id of current company.