/**
  * {@inheritdoc}
  */
 public function prepare($connection = null)
 {
     if (!is_null($connection)) {
         $this->connection = $connection;
         $this->prepared = true;
     }
     $tables = $this->getTablesOf($this->connection);
     $run = new ScriptBuilder(['indent' => 4, 'padding' => 8]);
     foreach ($tables as $key => $value) {
         if (in_array($value['table_name'], self::$ignoring)) {
             continue;
         }
         $destination = $this->dictionary->translate($table['table_name']);
         $records = $this->getDataOf($value['table_name']);
         $clause = new ScriptBuilder(['indent' => 4, 'padding' => 12]);
         foreach ($records as $record) {
             $clause->append('[')->lineBreak()->indent();
             foreach ($record as $column => $data) {
                 $clause->append($this->parse($column, $data, $this->dictionary->getColumnsOf($table['table_name'])))->lineBreak();
             }
             if ($this->hasRecords($records, 1)) {
                 $clause->unindent()->append('],')->lineBreak();
             } else {
                 $clause->unindent()->append(']')->lineBreak();
             }
         }
         if ($this->hasRecords($records)) {
             $run->append('DB::table("' . $destination . '")->insert([')->lineBreak()->append($clause->build(), false)->lineBreak()->append(']);')->lineBreak()->lineBreak();
         }
     }
     $this->records = $run;
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function render()
 {
     $up = new ScriptBuilder(['padding' => 8]);
     $down = new ScriptBuilder(['padding' => 8]);
     if (!is_null($this->schema) && count($this->schema)) {
         foreach ($this->schema as $name => $values) {
             if (in_array($name, self::$ignoring)) {
                 continue;
             }
             $up->append('/** Table: ' . $this->dictionary->translate($name) . ' */')->lineBreak()->append('{$values["up"]}', false)->lineBreak();
             $down->append('{$values["down"]}', false)->lineBreak();
         }
     }
     $template = file_get_contents(__DIR__ . '/templates/migration.txt');
     $template = str_replace('{{name}}', 'Create' . camel_case($this->connection) . 'Database', $template);
     $template = str_replace('{{up}}', $up->build(), $template);
     $template = str_replace('{{down}}', $down->build(), $template);
     return $template;
 }