|
1
|
|
|
<?php namespace Arcanesoft\Core\Bases; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\Support\Providers\RouteServiceProvider as ServiceProvider; |
|
4
|
|
|
use Illuminate\Support\Arr; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Class RouteServiceProvider |
|
8
|
|
|
* |
|
9
|
|
|
* @package Arcanesoft\Support\Providers |
|
10
|
|
|
* @author ARCANEDEV <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
abstract class RouteServiceProvider extends ServiceProvider |
|
13
|
|
|
{ |
|
14
|
|
|
/* ----------------------------------------------------------------- |
|
15
|
|
|
| Properties |
|
16
|
|
|
| ----------------------------------------------------------------- |
|
17
|
|
|
*/ |
|
18
|
|
|
/** |
|
19
|
|
|
* The admin controller namespace for the application. |
|
20
|
|
|
* |
|
21
|
|
|
* @var string|null |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $adminNamespace; |
|
24
|
|
|
|
|
25
|
|
|
/* ----------------------------------------------------------------- |
|
26
|
|
|
| Getters & Setters |
|
27
|
|
|
| ----------------------------------------------------------------- |
|
28
|
|
|
*/ |
|
29
|
|
|
/** |
|
30
|
|
|
* Get the config repository instance. |
|
31
|
|
|
* |
|
32
|
|
|
* @return \Illuminate\Contracts\Config\Repository |
|
33
|
|
|
*/ |
|
34
|
|
|
protected function config() |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->app->make('config'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/* ----------------------------------------------------------------- |
|
40
|
|
|
| Main Methods |
|
41
|
|
|
| ----------------------------------------------------------------- |
|
42
|
|
|
*/ |
|
43
|
|
|
/** |
|
44
|
|
|
* Group the routes with admin attributes. |
|
45
|
|
|
* |
|
46
|
|
|
* @param \Closure $callback |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function adminGroup(\Closure $callback) |
|
49
|
|
|
{ |
|
50
|
|
|
$attributes = $this->config()->get('arcanesoft.core.admin', []); |
|
51
|
|
|
|
|
52
|
|
|
$this->prefix(Arr::get($attributes, 'prefix', 'dashboard')) |
|
53
|
|
|
->name(Arr::get($attributes, 'name', 'admin::')) |
|
54
|
|
|
->namespace($this->adminNamespace) |
|
55
|
|
|
->middleware(Arr::get($attributes, 'middleware', ['web', 'auth', 'admin'])) |
|
56
|
|
|
->group($callback); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/* ----------------------------------------------------------------- |
|
60
|
|
|
| Deprecated Methods |
|
61
|
|
|
| ----------------------------------------------------------------- |
|
62
|
|
|
*/ |
|
63
|
|
|
/** |
|
64
|
|
|
* Get admin attributes. |
|
65
|
|
|
* |
|
66
|
|
|
* @deprecated: Use adminGroup(\Closure $callback) instead |
|
67
|
|
|
* |
|
68
|
|
|
* @param string $name |
|
69
|
|
|
* @param string $namespace |
|
70
|
|
|
* @param string $uri |
|
71
|
|
|
* @param array $middleware |
|
72
|
|
|
* |
|
73
|
|
|
* @return array |
|
74
|
|
|
*/ |
|
75
|
|
|
protected function getAdminAttributes($name, $namespace, $uri = '', array $middleware = []) |
|
76
|
|
|
{ |
|
77
|
|
|
return [ |
|
78
|
|
|
'as' => $this->prependAdminRouteName($name), |
|
|
|
|
|
|
79
|
|
|
'namespace' => $namespace, |
|
80
|
|
|
'prefix' => $this->prependAdminPrefixUri($uri), |
|
|
|
|
|
|
81
|
|
|
'middleware' => $this->getAdminMiddleware($middleware), |
|
|
|
|
|
|
82
|
|
|
]; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Prepend admin route name. |
|
87
|
|
|
* |
|
88
|
|
|
* @deprecated: Use adminGroup(\Closure $callback) instead |
|
89
|
|
|
* |
|
90
|
|
|
* @param string $name |
|
91
|
|
|
* |
|
92
|
|
|
* @return string |
|
93
|
|
|
*/ |
|
94
|
|
|
protected function prependAdminRouteName($name) |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->config()->get('arcanesoft.core.admin.route', 'admin::') . $name; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Prepend admin uri. |
|
101
|
|
|
* |
|
102
|
|
|
* @deprecated: Use adminGroup(\Closure $callback) instead |
|
103
|
|
|
* |
|
104
|
|
|
* @param string $uri |
|
105
|
|
|
* |
|
106
|
|
|
* @return string |
|
107
|
|
|
*/ |
|
108
|
|
|
protected function prependAdminPrefixUri($uri = '') |
|
109
|
|
|
{ |
|
110
|
|
|
$prefix = $this->config()->get('arcanesoft.core.admin.prefix', 'dashboard'); |
|
111
|
|
|
|
|
112
|
|
|
return trim("{$prefix}/{$uri}", '/'); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Get the admin middleware. |
|
117
|
|
|
* |
|
118
|
|
|
* @deprecated: Use adminGroup(\Closure $callback) instead |
|
119
|
|
|
* |
|
120
|
|
|
* @param array $append |
|
121
|
|
|
* |
|
122
|
|
|
* @return array|mixed |
|
123
|
|
|
*/ |
|
124
|
|
|
protected function getAdminMiddleware(array $append = []) |
|
125
|
|
|
{ |
|
126
|
|
|
$middleware = $this->config()->get('arcanesoft.core.admin.middleware', []); |
|
127
|
|
|
|
|
128
|
|
|
foreach ($append as $extra) { |
|
129
|
|
|
if ( ! in_array($extra, $middleware)) $middleware[] = $extra; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
return $middleware; |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.