Completed
Push — master ( 96dd95...b25769 )
by ARCANEDEV
02:59
created

LogViewerPolicy::getPolicies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
crap 1
1
<?php namespace Arcanesoft\Foundation\Policies;
2
3
use Arcanesoft\Contracts\Auth\Models\User;
4
5
/**
6
 * Class     LogViewerPolicy
7
 *
8
 * @package  Arcanesoft\Foundation\Policies
9
 * @author   ARCANEDEV <[email protected]>
10
 *
11
 * @todo: Adding the check role (LogViewer manager role)
12
 */
13
class LogViewerPolicy
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Getters and Setters
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Get the policies.
21
     *
22
     * @return array
23
     */
24 24
    public static function getPolicies()
25
    {
26
        return [
27 24
            'dashboardPolicy' => 'foundation.logviewer.dashboard',
28 18
            'listPolicy'      => 'foundation.logviewer.list',
29 18
            'showPolicy'      => 'foundation.logviewer.show',
30 18
            'downloadPolicy'  => 'foundation.logviewer.download',
31 18
            'deletePolicy'    => 'foundation.logviewer.delete',
32 18
        ];
33
    }
34
35
    /* ------------------------------------------------------------------------------------------------
36
     |  Policies Functions
37
     | ------------------------------------------------------------------------------------------------
38
     */
39
    /**
40
     * Allow to view the LogViewer dashboard.
41
     *
42
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
43
     *
44
     * @return bool
45
     */
46
    public function dashboardPolicy(User $user)
47
    {
48
        return $user->may('foundation.logviewer.dashboard');
49
    }
50
51
    /**
52
     * Allow to list all the logs.
53
     *
54
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
55
     *
56
     * @return bool
57
     */
58
    public function listPolicy(User $user)
59
    {
60
        return $user->may('foundation.logviewer.list');
61
    }
62
63
    /**
64
     * Allow to display a log.
65
     *
66
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
67
     *
68
     * @return bool
69
     */
70
    public function showPolicy(User $user)
71
    {
72
        return $user->may('foundation.logviewer.show');
73
    }
74
75
    /**
76
     * Allow to download a log.
77
     *
78
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
79
     *
80
     * @return bool
81
     */
82
    public function downloadPolicy(User $user)
83
    {
84
        return $user->may('foundation.logviewer.download');
85
    }
86
87
    /**
88
     * Allow to delete a log.
89
     *
90
     * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
91
     *
92
     * @return bool
93
     */
94
    public function deletePolicy(User $user)
95
    {
96
        return $user->may('foundation.logviewer.delete');
97
    }
98
}
99