1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omatech\Mage\Core; |
4
|
|
|
|
5
|
|
|
use Illuminate\Filesystem\Filesystem; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use Omatech\Mage\Core\Providers\BindingServiceProvider; |
8
|
|
|
|
9
|
|
|
class MageServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Bootstrap the application services. |
13
|
|
|
*/ |
14
|
74 |
|
public function boot() |
15
|
|
|
{ |
16
|
74 |
|
$this->publishes($this->migrations(), 'mage-migrations'); |
17
|
74 |
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Register the application services. |
21
|
|
|
*/ |
22
|
74 |
|
public function register() |
23
|
|
|
{ |
24
|
74 |
|
$this->mergeConfigFrom( |
25
|
74 |
|
__DIR__.'/../config/config.php', |
26
|
74 |
|
'mage' |
27
|
|
|
); |
28
|
|
|
|
29
|
74 |
|
$this->mergeConfigFrom( |
30
|
74 |
|
__DIR__.'/../config/permission.php', |
31
|
74 |
|
'permission' |
32
|
|
|
); |
33
|
|
|
|
34
|
74 |
|
$this->mergeConfigFrom( |
35
|
74 |
|
__DIR__.'/../config/auth.providers.php', |
36
|
74 |
|
'auth.providers' |
37
|
|
|
); |
38
|
|
|
|
39
|
74 |
|
$this->mergeConfigFrom( |
40
|
74 |
|
__DIR__.'/../config/auth.guards.php', |
41
|
74 |
|
'auth.guards' |
42
|
|
|
); |
43
|
|
|
|
44
|
74 |
|
$this->mergeConfigFrom( |
45
|
74 |
|
__DIR__.'/../config/translation-loader.php', |
46
|
74 |
|
'translation-loader' |
47
|
|
|
); |
48
|
|
|
|
49
|
74 |
|
$this->app->register(BindingServiceProvider::class); |
50
|
74 |
|
} |
51
|
|
|
|
52
|
74 |
|
public function migrations() |
53
|
|
|
{ |
54
|
74 |
|
$migrations = []; |
55
|
|
|
|
56
|
74 |
|
$filesystem = new Filesystem(); |
57
|
74 |
|
$source = __DIR__.'/database/migrations/'; |
58
|
74 |
|
$destination = $this->app->databasePath().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR; |
59
|
|
|
|
60
|
74 |
|
foreach ($filesystem->files($source) as $index => $file) { |
61
|
74 |
|
$sourceFileName = $file->getFilename(); |
62
|
74 |
|
$migrationName = substr($sourceFileName, 18, strlen($sourceFileName)); |
63
|
|
|
|
64
|
74 |
|
$fileExists = 0 != count($filesystem->glob($destination.'*'.$migrationName)); |
65
|
|
|
|
66
|
74 |
|
if (! $fileExists) { |
67
|
1 |
|
$destinationFileName = date('Y_m_d').'_'.str_pad($index, 6, '0').'_'.$migrationName; |
68
|
74 |
|
$migrations[$source.$sourceFileName] = $destination.$destinationFileName; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
74 |
|
return $migrations; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|