|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CodeZero\StageFront; |
|
4
|
|
|
|
|
5
|
|
|
use CodeZero\StageFront\Commands\DisableStageFront; |
|
6
|
|
|
use CodeZero\StageFront\Commands\EnableStageFront; |
|
7
|
|
|
use CodeZero\StageFront\Commands\SetCredentials; |
|
8
|
|
|
use CodeZero\StageFront\Composers\ThrottleTimeRemaining; |
|
9
|
|
|
use Illuminate\Support\ServiceProvider; |
|
10
|
|
|
|
|
11
|
|
|
class StageFrontServiceProvider extends ServiceProvider |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* The package name. |
|
15
|
|
|
* |
|
16
|
|
|
* @var string |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $name = 'stagefront'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Bootstrap any application services. |
|
22
|
|
|
* |
|
23
|
|
|
* @return void |
|
24
|
|
|
*/ |
|
25
|
29 |
|
public function boot() |
|
26
|
|
|
{ |
|
27
|
29 |
|
$this->loadRoutes(); |
|
28
|
29 |
|
$this->loadViews(); |
|
29
|
29 |
|
$this->loadViewComposers(); |
|
30
|
29 |
|
$this->loadTranslations(); |
|
31
|
29 |
|
$this->registerPublishableFiles(); |
|
32
|
29 |
|
$this->registerArtisanCommands(); |
|
33
|
29 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Register any application services. |
|
37
|
|
|
* |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
29 |
|
public function register() |
|
41
|
|
|
{ |
|
42
|
29 |
|
$this->mergeConfig(); |
|
43
|
29 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Load package routes. |
|
47
|
|
|
* |
|
48
|
|
|
* @return void |
|
49
|
|
|
*/ |
|
50
|
29 |
|
protected function loadRoutes() |
|
51
|
|
|
{ |
|
52
|
29 |
|
$this->loadRoutesFrom(__DIR__.'/../routes/routes.php'); |
|
53
|
29 |
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Load package views. |
|
57
|
|
|
* |
|
58
|
|
|
* @return void |
|
59
|
|
|
*/ |
|
60
|
29 |
|
protected function loadViews() |
|
61
|
|
|
{ |
|
62
|
29 |
|
$this->loadViewsFrom(__DIR__.'/../resources/views', $this->name); |
|
63
|
29 |
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Load the package view composers. |
|
67
|
|
|
* |
|
68
|
|
|
* @return void |
|
69
|
|
|
*/ |
|
70
|
29 |
|
protected function loadViewComposers() |
|
71
|
|
|
{ |
|
72
|
29 |
|
view()->composer('stagefront::429', ThrottleTimeRemaining::class); |
|
|
|
|
|
|
73
|
29 |
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Load package translations. |
|
77
|
|
|
* |
|
78
|
|
|
* @return void |
|
79
|
|
|
*/ |
|
80
|
29 |
|
protected function loadTranslations() |
|
81
|
|
|
{ |
|
82
|
29 |
|
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', $this->name); |
|
83
|
29 |
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Register the publishable files. |
|
87
|
|
|
* |
|
88
|
|
|
* @return void |
|
89
|
|
|
*/ |
|
90
|
29 |
|
protected function registerPublishableFiles() |
|
91
|
|
|
{ |
|
92
|
29 |
|
$this->publishes([ |
|
93
|
29 |
|
__DIR__."/../config/{$this->name}.php" => config_path("{$this->name}.php"), |
|
94
|
29 |
|
], 'config'); |
|
95
|
|
|
|
|
96
|
29 |
|
$this->publishes([ |
|
97
|
29 |
|
__DIR__."/../resources/views" => resource_path("views/vendor/{$this->name}"), |
|
98
|
29 |
|
], 'views'); |
|
99
|
|
|
|
|
100
|
29 |
|
$this->publishes([ |
|
101
|
29 |
|
__DIR__."/../resources/lang" => resource_path("lang/vendor/{$this->name}"), |
|
102
|
29 |
|
], 'lang'); |
|
103
|
29 |
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Merge published configuration file with |
|
107
|
|
|
* the original package configuration file. |
|
108
|
|
|
* |
|
109
|
|
|
* @return void |
|
110
|
|
|
*/ |
|
111
|
29 |
|
protected function mergeConfig() |
|
112
|
|
|
{ |
|
113
|
29 |
|
$this->mergeConfigFrom(__DIR__."/../config/{$this->name}.php", $this->name); |
|
114
|
29 |
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Register artisan commands. |
|
118
|
|
|
* |
|
119
|
|
|
* @return void |
|
120
|
|
|
*/ |
|
121
|
29 |
|
protected function registerArtisanCommands() |
|
122
|
|
|
{ |
|
123
|
29 |
|
if ($this->app->runningInConsole()) { |
|
124
|
29 |
|
$this->commands([ |
|
125
|
29 |
|
SetCredentials::class, |
|
126
|
|
|
EnableStageFront::class, |
|
127
|
|
|
DisableStageFront::class, |
|
128
|
|
|
]); |
|
129
|
|
|
} |
|
130
|
29 |
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: