1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Mpociot\Teamwork; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
|
7
|
|
|
class TeamworkServiceProvider extends ServiceProvider |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Bootstrap the application events. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function boot() |
15
|
|
|
{ |
16
|
|
|
$this->publishConfig(); |
17
|
|
|
$this->publishMigration(); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Publish Teamwork configuration. |
22
|
|
|
*/ |
23
|
|
|
protected function publishConfig() |
24
|
|
|
{ |
25
|
|
|
// Publish config files |
26
|
|
|
$this->publishes([ |
27
|
|
|
__DIR__.'/../config/config.php' => config_path('teamwork.php'), |
28
|
|
|
]); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Publish Teamwork migration. |
33
|
|
|
*/ |
34
|
|
|
protected function publishMigration() |
35
|
|
|
{ |
36
|
|
|
if (! class_exists('TeamworkSetupTables')) { |
37
|
|
|
// Publish the migration |
38
|
|
|
$timestamp = date('Y_m_d_His', time()); |
39
|
|
|
$this->publishes([ |
40
|
|
|
__DIR__.'/../database/migrations/2016_05_18_000000_teamwork_setup_tables.php' => database_path('migrations/'.$timestamp.'_teamwork_setup_tables.php'), |
41
|
|
|
], 'migrations'); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Register the service provider. |
47
|
|
|
* |
48
|
|
|
* @return void |
49
|
|
|
*/ |
50
|
|
|
public function register() |
51
|
|
|
{ |
52
|
|
|
$this->mergeConfig(); |
53
|
|
|
$this->registerTeamwork(); |
54
|
|
|
$this->registerCommands(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Register the application bindings. |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
protected function registerTeamwork() |
63
|
|
|
{ |
64
|
|
|
$this->app->alias(Teamwork::class, 'teamwork'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Merges user's and teamwork's configs. |
69
|
|
|
* |
70
|
|
|
* @return void |
71
|
|
|
*/ |
72
|
|
|
protected function mergeConfig() |
73
|
|
|
{ |
74
|
|
|
$this->mergeConfigFrom( |
75
|
|
|
__DIR__.'/../config/config.php', 'teamwork' |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Register scaffolding command. |
81
|
|
|
*/ |
82
|
|
|
protected function registerCommands() |
83
|
|
|
{ |
84
|
|
|
if ($this->app->runningInConsole()) { |
85
|
|
|
$this->commands([ |
86
|
|
|
Commands\MakeTeamwork::class, |
87
|
|
|
]); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|