Added new blade directive moduleIsEnabled and module_is_enabled helper function.

This commit is contained in:
Cüneyt Şentürk 2023-05-18 14:23:21 +03:00
parent 4bc8dc08fb
commit 2123bf34cf
2 changed files with 19 additions and 0 deletions

View File

@ -29,6 +29,10 @@ class Blade extends ServiceProvider
return "<?php echo show_widget($expression); ?>";
});
Facade::directive('moduleIsEnabled', function ($expression) {
return "<?php echo module_is_enabled($expression); ?>";
});
Facade::if('readonly', function () {
return config('read-only.enabled');
});

View File

@ -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.