Completed
Push — master ( b739db...92d607 )
by Abdelrahman
02:42
created

AbstractController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBroker() 0 4 1
A resourceAbilityMap() 0 13 1
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Http\Controllers;
17
18
use Illuminate\Routing\Controller;
19
use Rinvex\Fort\Traits\GetsMiddleware;
20
use Illuminate\Foundation\Bus\DispatchesJobs;
21
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
22
23
abstract class AbstractController extends Controller
24
{
25
    use AuthorizesRequests, DispatchesJobs, GetsMiddleware;
26
27
    /**
28
     * Resource Ability Map.
29
     *
30
     * Array of resource ability map.
31
     *
32
     * @var array
33
     */
34
    protected $resourceAbilityMap = [];
35
36
    /**
37
     * Whitelisted methods.
38
     *
39
     * Array of whitelisted methods which do not need to go through middleware.
40
     *
41
     * @var array
42
     */
43
    protected $middlewareWhitelist = [];
44
45
    /**
46
     * The password broker.
47
     *
48
     * @var string
49
     */
50
    protected $broker;
51
52
    /**
53
     * Get the broker to be used.
54
     *
55
     * @return string
56
     */
57
    protected function getBroker()
58
    {
59
        return $this->broker;
60
    }
61
62
    /**
63
     * Get the map of resource methods to ability names.
64
     *
65
     * @return array
66
     */
67
    protected function resourceAbilityMap()
68
    {
69
        return $this->resourceAbilityMap + [
70
            'show'    => 'view',
71
            'index'   => 'view',
72
            'bulk'    => 'bulk',
73
            'create'  => 'create',
74
            'store'   => 'create',
75
            'edit'    => 'update',
76
            'update'  => 'update',
77
            'destroy' => 'delete',
78
        ];
79
    }
80
}
81