Skip to content

Commit 44fe7ba

Browse files
committed
fix directory creation bug
1 parent 72e7665 commit 44fe7ba

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/DbExporter/DbExporter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ protected function getTableData($table)
103103
protected function makePath($path)
104104
{
105105
$del = DIRECTORY_SEPARATOR;
106-
$dir = $del;
106+
$dir ='';
107107
$directories = explode($del, $path);
108-
foreach ($directories as $key => $directory) {
109-
$dir.=$directory;
110-
if(!is_dir($dir)){
108+
foreach ($directories as $key => $directory) {
109+
if(!empty($directory))
110+
$dir.= $del.$directory;
111+
if(!is_dir($dir))
111112
@mkdir($dir);
112-
}
113-
}
113+
}
114114
}
115115

116116
/**

src/DbExporter/DbMigrations.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ public function write()
4343
}
4444

4545
$schema = $this->compile();
46-
$filename = date('Y_m_d_His') . "_create_" . $this->database . "_database.php";
47-
static::$filePath = Config::get('db-exporter.export_path.migrations') . "/{$filename}";
46+
$absolutePath = Config::get('db-exporter.export_path.migrations');
47+
$this->makePath($absolutePath);
48+
$this->filename = date('Y_m_d_His') . "_create_" . $this->database . "_database.php";
49+
static::$filePath = $absolutePath . "/{$this->filename}";
4850
file_put_contents(static::$filePath, $schema);
4951

5052
return static::$filePath;

0 commit comments

Comments
 (0)