|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Laravel Service Provider. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) DraperStudio <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace DraperStudio\ServiceProvider\Publisher; |
|
13
|
|
|
|
|
14
|
|
|
class MigrationPublisher extends Publisher |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* Get the source assets directory to publish. |
|
18
|
|
|
* |
|
19
|
|
|
* @param string $packagePath |
|
20
|
|
|
* |
|
21
|
|
|
* @return string |
|
22
|
|
|
* |
|
23
|
|
|
* @throws \InvalidArgumentException |
|
24
|
|
|
*/ |
|
25
|
|
|
protected function getSource($packagePath) |
|
26
|
|
|
{ |
|
27
|
|
|
$sources = [ |
|
28
|
|
|
"{$packagePath}/resources/database/migrations", |
|
29
|
|
|
"{$packagePath}/resources/migrations", |
|
30
|
|
|
"{$packagePath}/migrations", |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
// iterate through all possible locations |
|
34
|
|
|
foreach ($sources as $source) { |
|
35
|
|
|
if ($this->files->isDirectory($source)) { |
|
36
|
|
|
$paths = []; |
|
37
|
|
|
|
|
38
|
|
|
// get all files of the current directory |
|
39
|
|
|
$files = $this->getSourceFiles($source); |
|
40
|
|
|
|
|
41
|
|
|
// iterate through all files |
|
42
|
|
|
foreach ($files as $file) { |
|
43
|
|
|
// if the destination doesn't exist we can add the file to the queue |
|
44
|
|
|
if (!class_exists($this->getClassFromFile($file))) { |
|
45
|
|
|
$paths[$file] = $this->getDestinationPath('migrations', [ |
|
46
|
|
|
date('Y_m_d_His', time()), $this->getFileName($file), |
|
47
|
|
|
]); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return $paths; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
throw new InvalidArgumentException('Migrations not found.'); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|