Skip to content

Commit

Permalink
Updated Migrator to set path properly (#11)
Browse files Browse the repository at this point in the history
Laravel was passing in an array as the $path. A setPath() method was put in place to check against this. The requireFiles() method was also requiring the migrations but didn't have fully qualified paths.
  • Loading branch information
brandonferens authored and JayBizzle committed Aug 26, 2016
1 parent 00b3a69 commit bce8930
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,29 @@

class Migrator extends M
{
/**
* Fully qualified path to the application's migration directory
*
* @var string
*/
private $path;

/**
* Get all of the migration files in a given path.
*
* @param string $path
* @param bool $recursive
*
* @return array
*/
public function getMigrationFiles($path, $recursive = true)
{
$this->setPath($path);

if ($recursive === true) {
$files = $this->rglob($path.'/*_*.php', 0, true);
$files = $this->rglob($this->path.'/*_*.php', 0, true);
} else {
$files = $this->files->glob($path.'/*_*.php');
$files = $this->files->glob($this->path.'/*_*.php');
}

// Once we have the array of files in the directory we will just remove the
Expand All @@ -44,7 +54,6 @@ public function getMigrationFiles($path, $recursive = true)
/**
* Require in all the migration files in a given path.
*
* @param string $path
* @param array $files
*
* @return void
Expand Down Expand Up @@ -122,7 +131,7 @@ public function getFilePathWithFolders($file)
{
$datePath = $this->getDateFolderStructure($file);

return '/'.$datePath.$file;
return $this->path . '/' . $datePath . $file;
}

/**
Expand Down Expand Up @@ -150,4 +159,14 @@ public function getDateFolderStructure($file)

return $parts[0].'/'.$parts[1].'/';
}

/**
* Set the path
*
* @param array|string $path
*/
private function setPath($path)
{
$this->path = is_array($path) ? $path[0] : $path;
}
}

0 comments on commit bce8930

Please sign in to comment.