public function reload() { if (AccessHelper::is_allowed()) { $lists = array_diff(scandir(app_path() . "/Addons"), array('..', '.')); foreach ($lists as $key => $value) { $__erp__ = app_path() . "/Addons/{$value}/__erp__.php"; if (file_exists($__erp__)) { $addons = Addons::where('dir', '=', $value)->first(); if ($addons) { $installed = $addons->is_installed; } else { $installed = "0"; } include $__erp__; Addons::where('dir', '=', $value)->update(["name" => $erp['name'], "version" => $erp['version'], "category" => $erp['category'], "description" => $erp['description'], "url" => $erp['website'], "dir" => $value, "is_installed" => $installed, "author" => $erp['author']]); } } return \Redirect::to('settings/addons'); } else { return \View('Base::Base.forbiden'); } }
/** * Will make sure that the required modules have been fully loaded * @return void */ public function boot() { $lists = array_diff(scandir(app_path() . "/Addons"), array('..', '.')); foreach ($lists as $key => $value) { $__erp__ = app_path() . "/Addons/{$value}/__erp__.php"; if (file_exists($__erp__)) { include $__erp__; $data = Addons::where('dir', '=', $value)->first(); if ($data == null) { if ($value == "Base") { Addons::insert(["name" => $erp['name'], "version" => $erp['version'], "category" => $erp['category'], "description" => $erp['description'], "url" => $erp['website'], "dir" => $value, "is_installed" => "1", "author" => $erp['author']]); } else { Addons::insert(["name" => $erp['name'], "version" => $erp['version'], "category" => $erp['category'], "description" => $erp['description'], "url" => $erp['website'], "dir" => $value, "is_installed" => "0", "author" => $erp['author']]); } } } // cek jika module sudah di install $is_installed = Addons::where('dir', '=', $value)->where('is_installed', '=', "1")->first(); if ($is_installed) { // Load the routes for each of the addons if (file_exists(app_path() . "/Addons/{$value}/routes.php")) { include app_path() . "/Addons/{$value}/routes.php"; } // Load the views if (is_dir(app_path() . "/Addons/{$value}/Views")) { $this->loadViewsFrom(app_path() . "/Addons/{$value}/Views", $value); } $total = count(RoutesModel::getRoutes()['data']['method']); for ($x = 0; $x < $total; $x++) { $cekrut = RoutesModel::where('method', '=', RoutesModel::getRoutes()['data']['method'][$x])->where('route', '=', RoutesModel::getRoutes()['data']['path'][$x])->where('action', '=', RoutesModel::getRoutes()['data']['action'][$x])->first(); if ($cekrut == null) { RoutesModel::insert(["method" => RoutesModel::getRoutes()['data']['method'][$x], "route" => RoutesModel::getRoutes()['data']['path'][$x], "action" => RoutesModel::getRoutes()['data']['action'][$x]]); } } } } }