1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Chriscreates\Projects; |
4
|
|
|
|
5
|
|
|
use Chriscreates\Projects\Commands\CreateTaskCommand; |
6
|
|
|
use Chriscreates\Projects\Commands\ProjectsConfigCommand; |
7
|
|
|
use Chriscreates\Projects\Commands\ProjectsSeederCommand; |
8
|
|
|
use Illuminate\Database\Eloquent\Factory; |
9
|
|
|
use Illuminate\Support\ServiceProvider; |
10
|
|
|
|
11
|
|
|
class ProjectsServiceProvider extends ServiceProvider |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Bootstrap the application services. |
15
|
|
|
*/ |
16
|
|
|
public function boot() |
17
|
|
|
{ |
18
|
|
|
$this->bootFactories(projects_base_path('/database/factories')); |
19
|
|
|
|
20
|
|
|
$this->handleMigrations(); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
protected function bootFactories($path) |
24
|
|
|
{ |
25
|
|
|
$this->app->make(Factory::class)->load($path); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Register bindings in the container. |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function register() |
34
|
|
|
{ |
35
|
|
|
$this->registerCommands(); |
36
|
|
|
|
37
|
|
|
foreach (glob(__DIR__.'/Helpers/*.php') as $file) { |
38
|
|
|
require_once($file); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Register the package's migrations. |
44
|
|
|
* |
45
|
|
|
* @return void |
46
|
|
|
*/ |
47
|
|
|
private function handleMigrations() |
48
|
|
|
{ |
49
|
|
|
if ($this->app->runningUnitTests()) { |
50
|
|
|
$this->loadMigrationsFrom(projects_base_path('/database/test_migrations')); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
if ($this->app->runningInConsole()) { |
54
|
|
|
$this->loadMigrationsFrom(projects_base_path('/database/migrations')); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return void |
60
|
|
|
*/ |
61
|
|
|
private function registerCommands() |
62
|
|
|
{ |
63
|
|
|
$this->commands([ |
64
|
|
|
ProjectsConfigCommand::class, |
65
|
|
|
ProjectsSeederCommand::class, |
66
|
|
|
CreateTaskCommand::class, |
67
|
|
|
]); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|