|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ck\Laravel\Alice; |
|
4
|
|
|
|
|
5
|
|
|
use Ck\Laravel\Alice\Persister\EloquentPersister; |
|
6
|
|
|
use Ck\Laravel\Alice\Loader\Loader; |
|
7
|
|
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
|
8
|
|
|
|
|
9
|
|
|
class ServiceProvider extends BaseServiceProvider |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Bootstrap the application services. |
|
13
|
|
|
* |
|
14
|
|
|
* @return void |
|
15
|
|
|
*/ |
|
16
|
|
|
public function boot() |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Register the application services. |
|
23
|
|
|
* |
|
24
|
|
|
* @return void |
|
25
|
|
|
*/ |
|
26
|
|
|
public function register() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->registerConfig(); |
|
29
|
|
|
$this->registerPersister(); |
|
30
|
|
|
$this->registerLoader(); |
|
31
|
|
|
$this->registerCommand(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
private function registerConfig() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/alice.php','alice'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
private function registerPersister() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->app->singleton('alice.eloquent_persister', function($app) { |
|
42
|
|
|
return new EloquentPersister($app->make('db.connection')); |
|
43
|
|
|
}); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
private function registerLoader() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->app->singleton('alice.loader', function($app) { |
|
49
|
|
|
|
|
50
|
|
|
$config = $app->make('config'); |
|
51
|
|
|
|
|
52
|
|
|
return new Loader( |
|
53
|
|
|
$app->make('alice.eloquent_persister'), |
|
54
|
|
|
$config->get('alice.locale'), |
|
55
|
|
|
$config->get('alice.providers'), |
|
56
|
|
|
$config->get('alice.seed'), |
|
57
|
|
|
$config->all() |
|
58
|
|
|
); |
|
59
|
|
|
}); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
private function registerCommand() |
|
63
|
|
|
{ |
|
64
|
|
|
$this->app->singleton('alice.command', function ($app) { |
|
65
|
|
|
return $app->make('Ck\Laravel\Alice\Command\SeedCommand'); |
|
66
|
|
|
}); |
|
67
|
|
|
|
|
68
|
|
|
$this->commands('alice.command'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|