ask('What is the tmp table name with users data ?'); try { DB::connection(config('database.oldDB'))->table($table)->exists(); } catch (\Exception $e) { $this->error(sprintf('%s table not found on old crm database', $table)); return -1; } $brandname = $this->ask('What is the brand name ?'); $brand = Brand::query()->where('name', 'LIKE', "%$brandname%")->first(); if (!$brand) { if (!$this->confirm(sprintf('Would you like to use %s ? ', $brandname))) { $this->info('Command cancelled'); return 0; } if ($this->confirm('Would you like to create a new one ?')) { $brand = new Brand(); $brand->name = $brandname; $brand->save(); } else { $this->info('Command cancelled'); return 0; } } $mgOldData = new MigrateOldData(); $mgOldData->runMigration($brand, $table); } catch (\Exception $e) { $this->error(sprintf('Failed %s', $e)); return -1; } //end try return 0; } }