Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     try {
         parent::fire();
         $env = self::detectEnvironment();
         $source = $this->argument('source');
         $seeded = getSeeded($env);
         $collection = collect([]);
         $provider = ProviderFactory::factory($source, $env);
         if (is_array($provider) && !empty($provider['run'])) {
             $closure = $provider['run'];
             if (!self::isClosure($closure)) {
                 throw new SeederException('Invalid closure declared to config file');
             }
             $collection = $closure($source, $seeded, $env, $this);
         } elseif ($provider instanceof ProviderInterface) {
             $collection = $provider->getData($source, $seeded);
         }
         if ($collection->isEmpty()) {
             throw new SeederException('No seeds data!');
         }
         App::make('smart.seed.table', [$this])->seed($collection, $env);
     } catch (SeederException $e) {
         $this->error($e->getMessage());
     }
 }
Ejemplo n.º 2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     try {
         parent::fire();
         $repository = app('smart.seed.repository');
         $env = self::detectEnvironment();
         $lastBatch = $repository->getLastBatch($env);
         $rollbackSeeds = $repository->getSeeds($env, $lastBatch);
         if (!count($rollbackSeeds)) {
             throw new SeederException('No seeds to rollback!');
         }
         App::make('smart.seed.table', [$this])->rollback($rollbackSeeds);
     } catch (SeederException $e) {
         $this->error($e->getMessage());
     }
 }
Ejemplo n.º 3
0
 /**
  * Execute the console command.
  *
  * @throws SeederException
  * @return mixed
  */
 public function fire()
 {
     try {
         parent::fire();
         if (!$this->argument('source')) {
             throw new SeederException('Invalid source!');
         }
         $env = self::detectEnvironment();
         $source = $this->argument('source');
         $provider = ProviderFactory::factory($source, $env);
         if (is_array($provider) && !empty($provider['create'])) {
             $closure = $provider['create'];
             if (!self::isClosure($closure)) {
                 throw new SeederException('Invalid closure declared to config file');
             }
             $closure($source, $env, $this);
         } elseif ($provider instanceof ProviderInterface) {
             $provider->create($this);
         }
     } catch (SeederException $e) {
         $this->error($e->getMessage());
     }
 }