Completed
Push — master ( 8c3d30...58cef5 )
by Daniel
01:19
created

HasGates::gateDenies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Fireworkweb\Gates\Traits;
4
5
trait HasGates
6
{
7
    public function gateAllows()
8
    {
9
        return true;
10
    }
11
12
    public function gateDenies()
13
    {
14
        return false;
15
    }
16
17
    protected static function gateRouteName(): string
18
    {
19
        // @TODO: add magic way
20
        return '';
21
    }
22
23
    protected static function gateAbilities(): array
24
    {
25
        return [];
26
    }
27
28
    protected static function gateResourceAbilities(): array
29
    {
30
        return [
31
            'index' => 'index',
32
            'create' => 'create',
33
            'store' => 'store',
34
            'show' => 'show',
35
            'edit' => 'edit',
36
            'update' => 'update',
37
            'destroy' => 'destroy',
38
        ];
39
    }
40
41
    public static function gateRegister(): void
42
    {
43
        gate()->resource(
44
            static::gateRouteName(),
45
            __CLASS__,
46
            static::gateAbilities()
47
        );
48
    }
49
}
50