Ejemplo n.º 1
0
 /**
  * @param string $name
  * @return string
  */
 public function create($name)
 {
     $fileName = date('ymd_His_') . $name . '.php';
     $filePath = $this->config->getPath() . '/' . $fileName;
     if (file_exists($filePath) || !is_dir($this->config->getPath())) {
         throw new InvalidArgumentException(sprintf('cannot write the file at %s.', $filePath));
     }
     $contents = $this->template->getContext($name);
     file_put_contents($filePath, $contents);
     return $filePath;
 }
Ejemplo n.º 2
0
 /**
  * @return array
  */
 protected function getAllMigrationFiles()
 {
     $files = [];
     foreach (new DirectoryIterator($this->config->getPath()) as $file) {
         if ($file->isDot() || $file->isDir() || $file->getFilename()[0] === '.') {
             continue;
         }
         $files[] = $file->getFileInfo();
     }
     usort($files, function (SplFileInfo $file, SplFileInfo $nextFile) {
         if ($file->getFilename() > $nextFile->getFilename()) {
             return 1;
         }
         return $file->getFilename() < $nextFile->getFilename() ? -1 : 0;
     });
     return $files;
 }
Ejemplo n.º 3
0
 /**
  * @param \Illuminate\Database\Capsule\Manager $manager
  * @param \Wandu\Database\Migrator\Configuration $config
  */
 public function __construct(Manager $manager, Configuration $config)
 {
     $this->tableName = $config->getTable();
     $this->connection = $manager->getConnection($config->getConnection());
 }