|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Support\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Support\Http\ApiResponse; |
|
6
|
|
|
use Illuminate\Contracts\Routing\ResponseFactory; |
|
7
|
|
|
use Illuminate\Support\ServiceProvider; |
|
8
|
|
|
|
|
9
|
|
|
class SupportServiceProvider extends ServiceProvider |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Bootstrap the service provider. |
|
13
|
|
|
*/ |
|
14
|
1 |
|
public function boot() |
|
15
|
|
|
{ |
|
16
|
1 |
|
$this->extendResponses(); |
|
17
|
1 |
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Extend responses. |
|
21
|
|
|
*/ |
|
22
|
1 |
|
protected function extendResponses() |
|
23
|
|
|
{ |
|
24
|
1 |
|
$response = $this->app->make(ResponseFactory::class); |
|
25
|
|
|
|
|
26
|
1 |
|
$response->macro('api', function (...$args) { |
|
27
|
|
|
return new ApiResponse(...$args); |
|
28
|
1 |
|
}); |
|
29
|
1 |
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Register the service provider. |
|
33
|
|
|
*/ |
|
34
|
1 |
|
public function register() |
|
35
|
|
|
{ |
|
36
|
1 |
|
array_map([$this->app, 'register'], $this->getServiceProviders()); |
|
37
|
1 |
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Get service providers to be registered. |
|
41
|
|
|
* |
|
42
|
|
|
* @return array |
|
43
|
|
|
*/ |
|
44
|
1 |
|
protected function getServiceProviders() |
|
45
|
|
|
{ |
|
46
|
|
|
$services = [ |
|
47
|
1 |
|
AppConfigServiceProvider::class, |
|
48
|
|
|
CaptchaServiceProvider::class, |
|
49
|
|
|
ClientServiceProvider::class, |
|
50
|
|
|
OptimusServiceProvider::class, |
|
51
|
|
|
XgPusherServiceProvider::class, |
|
52
|
|
|
]; |
|
53
|
|
|
|
|
54
|
1 |
|
if ($this->app->runningInConsole()) { |
|
55
|
1 |
|
array_push( |
|
56
|
|
|
$services, |
|
57
|
1 |
|
ConsoleServiceProvider::class, |
|
58
|
1 |
|
\Laravel\Tinker\TinkerServiceProvider::class, |
|
59
|
1 |
|
\BackupManager\Laravel\Laravel5ServiceProvider::class |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
1 |
|
if ($this->app->isLocal()) { |
|
64
|
|
|
array_push( |
|
65
|
|
|
$services, |
|
66
|
|
|
\Barryvdh\Debugbar\ServiceProvider::class, |
|
67
|
|
|
\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class |
|
68
|
|
|
); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
1 |
|
return $services; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|