RouteServiceProvider::getAdminAttributes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php namespace Arcanesoft\Core\Bases;
2
3
use Arcanedev\Support\Providers\RouteServiceProvider as ServiceProvider;
4
use Closure;
5
use Illuminate\Support\Arr;
6
7
/**
8
 * Class     RouteServiceProvider
9
 *
10
 * @package  Arcanesoft\Support\Providers
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
abstract class RouteServiceProvider extends ServiceProvider
14
{
15
    /* -----------------------------------------------------------------
16
     |  Properties
17
     | -----------------------------------------------------------------
18
     */
19
20
    /**
21
     * The admin controller namespace for the application.
22
     *
23
     * @var string|null
24
     */
25
    protected $adminNamespace;
26
27
    /* -----------------------------------------------------------------
28
     |  Getters & Setters
29
     | -----------------------------------------------------------------
30
     */
31
32
    /**
33
     * Get the config repository instance.
34
     *
35
     * @return \Illuminate\Contracts\Config\Repository
36
     */
37
    protected function config()
38
    {
39
        return $this->app['config'];
40
    }
41
42
    /**
43
     * Get the admin route attributes.
44
     *
45
     * @return array
46
     */
47
    protected function getAdminAttributes()
48
    {
49
        return $this->config()->get('arcanesoft.core.admin', []);
50
    }
51
52
    /* -----------------------------------------------------------------
53
     |  Main Methods
54
     | -----------------------------------------------------------------
55
     */
56
57
    /**
58
     * Group the routes with admin attributes.
59
     *
60
     * @param  \Closure  $callback
61
     */
62
    protected function adminGroup(Closure $callback)
63
    {
64
        $attributes = $this->getAdminAttributes();
65
66
        $this->prefix(Arr::get($attributes, 'prefix', 'dashboard'))
67
             ->name(Arr::get($attributes, 'name', 'admin::'))
68
             ->namespace($this->adminNamespace)
69
             ->middleware(Arr::get($attributes, 'middleware', ['web', 'auth', 'admin']))
70
             ->group($callback);
71
    }
72
}
73