module_name = 'professionalproject'; $this->appVersion = config('professionalproject.module_version'); } public function index() { if (! auth()->user()->can('superadmin')) { abort(403, 'Unauthorized action.'); } ini_set('max_execution_time', 0); ini_set('memory_limit', '512M'); $this->installSettings(); if (! empty(System::getProperty($this->module_name.'_version'))) { abort(404); } return view('install.install-module') ->with([ 'action_url' => action([self::class, 'install']), 'intruction_type' => 'uf', ]); } public function install() { try { DB::beginTransaction(); request()->validate([ 'license_code' => 'required', 'login_username' => 'required', ]); if (! empty(System::getProperty($this->module_name.'_version'))) { abort(404); } DB::statement('SET default_storage_engine=INNODB;'); Artisan::call('module:migrate', ['module' => 'ProfessionalProject', '--force' => true]); System::addProperty($this->module_name.'_version', $this->appVersion); DB::commit(); $output = ['success' => 1, 'msg' => __('professionalproject::lang.module_installed')]; } catch (\Exception $e) { DB::rollBack(); \Log::emergency('File:'.$e->getFile().'Line:'.$e->getLine().'Message:'.$e->getMessage()); $output = ['success' => false, 'msg' => $e->getMessage()]; } return redirect() ->action([\App\Http\Controllers\Install\ModulesController::class, 'index']) ->with('status', $output); } public function uninstall() { if (! auth()->user()->can('superadmin')) { abort(403, 'Unauthorized action.'); } try { System::removeProperty($this->module_name.'_version'); $output = ['success' => true, 'msg' => __('lang_v1.success')]; } catch (\Exception $e) { $output = ['success' => false, 'msg' => $e->getMessage()]; } return redirect()->back()->with(['status' => $output]); } public function update() { if (! auth()->user()->can('superadmin')) { abort(403, 'Unauthorized action.'); } try { DB::beginTransaction(); ini_set('max_execution_time', 0); ini_set('memory_limit', '512M'); $current = System::getProperty($this->module_name.'_version'); if (Comparator::greaterThan($this->appVersion, $current)) { $this->installSettings(); DB::statement('SET default_storage_engine=INNODB;'); Artisan::call('module:migrate', ['module' => 'ProfessionalProject', '--force' => true]); System::setProperty($this->module_name.'_version', $this->appVersion); } else { abort(404); } DB::commit(); $output = ['success' => 1, 'msg' => __('professionalproject::lang.module_updated', ['version' => $this->appVersion])]; } catch (\Exception $e) { DB::rollBack(); exit($e->getMessage()); } return redirect()->back()->with(['status' => $output]); } private function installSettings() { config(['app.debug' => true]); Artisan::call('config:clear'); } }