Example #1
0
 public function anyModules($action = "view")
 {
     $aModules = Arxmin::getModulesAvailables();
     if ($action == 'download') {
         $result = Module::download(Input::get('link'), Input::get('name'), \Module::getPath());
     }
     $title = trans("Modules Discovery");
     /*$oModules = Arxmin::getModules();
     
             foreach ($oModules as $module) {
     
                 $aModules[] = [
                     'title' => $module->name,
                     'description' => $module->name,
                 ];
             }*/
     return $this->viewMake('arxmin::modules.home', get_defined_vars());
 }
Example #2
0
 function modulePath($path)
 {
     return \Arxmin\Module::modulePath($path);
 }
Example #3
0
 /**
  * Method to guess the current module used
  *
  * @todo : improve this method
  */
 public static function guestCurrentModule()
 {
     $aDebug = debug_backtrace(1);
     $modules = \Module::all();
     if (isset($aDebug[1])) {
         foreach ($aDebug as $item) {
             if (isset($item['file'])) {
                 foreach ($modules as $module) {
                     if (strpos($item['file'], $module->path)) {
                         self::$currentModule = $module->name;
                         Module::setCurrent($module->name);
                         break;
                     }
                 }
             }
         }
     } else {
         throw new \Exception('Cannot set current module dynamically');
     }
 }
Example #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('This will install the Arxmin Package in your project and set a default admin user');
     /*if (!$this->confirm("Do you wish to continue?", true)) {
           $this->info('Goodbye !');
           exit;
       }*/
     /**
      * Step 1 Check if project have arxmin_tables
      */
     if (!SchemaModel::hasTable('arxmin_options')) {
         $this->info('Installing the Arxmin tables');
         # Publish Arxmin Migrations
         exec('php artisan vendor:publish --provider="Arxmin\\ArxminServiceProvider" --tag="migrations"');
         if ($this->confirm('Do you wish to run artisan:migrate ? (please make sure that you\'ve run all your migrations first)', true)) {
             $this->call('migrate');
         }
     }
     /**
      * Check the project name
      */
     if (SchemaModel::hasTable('arxmin_options') && !Arxmin::hasOption('project_name')) {
         $project = $this->ask('What\'s the name of your project?');
         Arxmin::setOption('project_name', $project);
         $this->info('Project name setted as ' . $project);
     }
     /**
      * Check if a user is defined. If not, it will create a new one as admin
      */
     if (SchemaModel::hasTable('arxmin_users') && !User::where('role', User::ROLE_ADMIN)->first()) {
         $name = $this->ask('Hi there, what\'s your name?');
         $email = $this->ask('And your email?');
         $password = $this->ask('Please enter your password');
         $user = new User();
         $user->name = $name;
         $user->email = $email;
         $user->password = bcrypt($password);
         $user->role = User::ROLE_ADMIN;
         $user->save();
         $this->info('You are defined as an admin ' . $name);
     }
     if (!file_exists(base_path('modules'))) {
         $this->info('Create modules folder');
         mkdir(base_path('modules'));
     }
     if (!file_exists(storage_path('app/modules'))) {
         $this->info('Create modules folder');
         mkdir(storage_path('app/modules'));
     }
     touch(storage_path('app/modules/modules.used'));
     $modules = Arxmin::getModulesAvailables();
     $list = array_map(function ($item) {
         return $item['name'] . ' : ' . $item['description'];
     }, $modules);
     /**
      * @var $choices Array
      */
     $choices = $this->choice('Do you want to install some available module ? (enter the number separate by comma ex: 0,2)', $list, 0, null, true);
     foreach ($choices as $key => $name) {
         $ref = array_search($name, $list);
         $module = $modules[$ref];
         $result = Arxmin\Module::download($module['link'], $module['name']);
         if ($result) {
             $this->info($module['name'] . ' successfully installed');
         }
         $result = exec('composer dump-autoload');
         if ($result) {
             if ($this->confirm('Would you like to enable the module ?', true)) {
                 $this->call('module:use ' . $module['name']);
             }
             if ($this->confirm('Would you like to run the ' . $module['name'] . ' migration ?')) {
                 $this->call('module:publish-migrations ' . $module['name']);
                 $this->call('migrate');
             }
         }
     }
     $this->info('Module installed');
     $this->call('module:list');
     $this->info('Arxmin is successfully installed !');
     $this->info('You can go here : ' . url('/arxmin/login'));
 }
Example #5
0
 /**
  * Apply current module
  *
  * @param $name
  */
 public static function setUsed($name)
 {
     self::$currentModule = $name;
     parent::setUsed($name);
 }