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 |
|
\BackupManager\Laravel\Laravel5ServiceProvider::class |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
if ($this->app->isLocal()) { |
63
|
|
|
array_push( |
64
|
|
|
$services, |
65
|
|
|
\Barryvdh\Debugbar\ServiceProvider::class, |
66
|
|
|
\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
1 |
|
return $services; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|