Server : Apache System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64 User : tradze ( 1001) PHP Version : 8.1.34 Disable Function : NONE Directory : /home/tradze/public_html/app/Services/ |
<?php
namespace App\Services;
class ModuleService
{
protected $path;
protected $enabled = [];
public function __construct()
{
$this->path = config('modules.path', app_path('Modules'));
}
/**
* Check if a module is enabled (exists and has routes/provider).
*
* @param string $name Module name (e.g. 'schedules', 'blog')
* @return bool
*/
public function isEnabled($name)
{
$name = strtolower($name);
if (isset($this->enabled[$name])) {
return $this->enabled[$name];
}
$path = $this->path . '/' . ucfirst($name);
$this->enabled[$name] = is_dir($path) && (
file_exists($path . '/Http/routes.php') ||
file_exists($path . '/Providers/' . ucfirst($name) . 'ServiceProvider.php')
);
return $this->enabled[$name];
}
/**
* Get list of available module names.
*
* @return array
*/
public function all()
{
if (!is_dir($this->path)) {
return [];
}
$dirs = glob($this->path . '/*', GLOB_ONLYDIR);
return array_map('basename', $dirs);
}
}