Nwidart\Modules\Repository::getOrdered PHP Method

getOrdered() public method

Get all ordered modules.
public getOrdered ( string $direction = 'asc' ) : array
$direction string
return array
    public function getOrdered($direction = 'asc')
    {
        $modules = $this->enabled();
        uasort($modules, function (Module $a, Module $b) use($direction) {
            if ($a->order == $b->order) {
                return 0;
            }
            if ($direction == 'desc') {
                return $a->order < $b->order ? 1 : -1;
            }
            return $a->order > $b->order ? 1 : -1;
        });
        return $modules;
    }

Usage Example

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->module = $this->laravel['modules'];
     $name = $this->argument('module');
     if ($name) {
         $module = $this->module->findOrFail($name);
         return $this->migrate($module);
     }
     foreach ($this->module->getOrdered($this->option('direction')) as $module) {
         $this->line('Running for module: <info>' . $module->getName() . '</info>');
         $this->migrate($module);
     }
 }
All Usage Examples Of Nwidart\Modules\Repository::getOrdered