Code Duplication    Length = 81-81 lines in 5 locations

app/Policies/DevicePolicy.php 1 location

@@ 9-89 (lines=81) @@
6
use App\Device;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class DevicePolicy
10
{
11
    use HandlesAuthorization;
12
13
    /**
14
     * Determine whether the user can view the list of devices.
15
     *
16
     * @param  \App\User  $user
17
     * @return mixed
18
     */
19
    public function index(User $user)
20
    {
21
        return $user->isManager();
22
    }
23
    
24
    /**
25
     * Determine whether the user can view a device.
26
     *
27
     * @param  \App\User  $user
28
     * @return mixed
29
     */
30
    public function show(User $user)
31
    {
32
        return $user->isUser();
33
    }
34
    
35
    /**
36
     * Determine whether the user can view the edit page for a device.
37
     *
38
     * @param  \App\User  $user
39
     * @return mixed
40
     */
41
    public function edit(User $user)
42
    {
43
        return $user->isManager();
44
    }
45
    
46
    /**
47
     * Determine whether the user can update the device.
48
     *
49
     * @param  \App\User  $user
50
     * @return mixed
51
     */
52
    public function update(User $user)
53
    {
54
        return $user->isManager();
55
    }
56
    
57
    /**
58
     * Determine whether the user can update the device's command.
59
     *
60
     * @param  \App\User  $user
61
     * @return mixed
62
     */
63
    public function updateCommand(User $user)
64
    {
65
        return $user->isUser();
66
    }
67
    
68
    /**
69
     * Determine whether the user can delete the device.
70
     *
71
     * @param  \App\User  $user
72
     * @return mixed
73
     */
74
    public function destroy(User $user)
75
    {
76
        return $user->isAdmin();
77
    }
78
    
79
    /**
80
     * Determine whether the user can restore the device.
81
     *
82
     * @param  \App\User  $user
83
     * @return mixed
84
     */
85
    public function restore(User $user)
86
    {
87
        return $user->isAdmin();
88
    }
89
}
90

app/Policies/LocationPolicy.php 1 location

@@ 9-89 (lines=81) @@
6
use App\Location;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class LocationPolicy
10
{
11
    use HandlesAuthorization;
12
    
13
    /**
14
     * Determine whether the user can view the location.
15
     *
16
     * @param  \App\User  $user
17
     * @return mixed
18
     */
19
    public function index(User $user)
20
    {
21
        return $user->isManager();
22
    }
23
    
24
    /**
25
     * Determine whether the user can view the create location page.
26
     *
27
     * @param  \App\User  $user
28
     * @return mixed
29
     */
30
    public function create(User $user)
31
    {
32
        return $user->isManager();
33
    }
34
    
35
    /**
36
     * Determine whether the user can create a location.
37
     *
38
     * @param  \App\User  $user
39
     * @return boolean
40
     */
41
    public function store(User $user)
42
    {
43
        return $user->isManager();
44
    }
45
    
46
    /**
47
     * Determine whether the user can view a location.
48
     *
49
     * @param  \App\User  $user
50
     * @return mixed
51
     */
52
    public function show(User $user)
53
    {
54
        return $user->isUser();
55
    }
56
    
57
    /**
58
     * Determine whether the user can view the edit page for a location.
59
     *
60
     * @param  \App\User  $user
61
     * @return mixed
62
     */
63
    public function edit(User $user)
64
    {
65
        return $user->isManager();
66
    }
67
    
68
    /**
69
     * Determine whether the user can update the location.
70
     *
71
     * @param  \App\User  $user
72
     * @return mixed
73
     */
74
    public function update(User $user)
75
    {
76
        return $user->isManager();
77
    }
78
    
79
    /**
80
     * Determine whether the user can delete the location.
81
     *
82
     * @param  \App\User  $user
83
     * @return mixed
84
     */
85
    public function destroy(User $user)
86
    {
87
        return $user->isManager();
88
    }
89
}
90

app/Policies/SensorDataPolicy.php 1 location

@@ 9-89 (lines=81) @@
6
use App\SensorData;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class SensorDataPolicy
10
{
11
    use HandlesAuthorization;
12
    
13
    /**
14
     * Determine whether the user can view the sensor data.
15
     *
16
     * @param  \App\User  $user
17
     * @return mixed
18
     */
19
    public function index(User $user)
20
    {
21
        return $user->isAdmin();
22
    }
23
    
24
    /**
25
     * Determine whether the user can view the create sensor data page.
26
     *
27
     * @param  \App\User  $user
28
     * @return mixed
29
     */
30
    public function create(User $user)
31
    {
32
        return $user->isAdmin();
33
    }
34
    
35
    /**
36
     * Determine whether the user can create sensor data.
37
     *
38
     * @param  \App\User  $user
39
     * @return boolean
40
     */
41
    public function store(User $user)
42
    {
43
        return $user->isAdmin();
44
    }
45
    
46
    /**
47
     * Determine whether the user can view a sensor data.
48
     *
49
     * @param  \App\User  $user
50
     * @return mixed
51
     */
52
    public function show(User $user)
53
    {
54
        return $user->isUser();
55
    }
56
    
57
    /**
58
     * Determine whether the user can view the edit page for a sensor data.
59
     *
60
     * @param  \App\User  $user
61
     * @return mixed
62
     */
63
    public function edit(User $user)
64
    {
65
        return $user->isAdmin();
66
    }
67
    
68
    /**
69
     * Determine whether the user can update the sensor data.
70
     *
71
     * @param  \App\User  $user
72
     * @return mixed
73
     */
74
    public function update(User $user)
75
    {
76
        return $user->isAdmin();
77
    }
78
    
79
    /**
80
     * Determine whether the user can delete the sensor data.
81
     *
82
     * @param  \App\User  $user
83
     * @return mixed
84
     */
85
    public function destroy(User $user)
86
    {
87
        return $user->isAdmin();
88
    }
89
}
90

app/Policies/SensorPolicy.php 1 location

@@ 9-89 (lines=81) @@
6
use App\Sensor;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class SensorPolicy
10
{
11
    use HandlesAuthorization;
12
    
13
    /**
14
     * Determine whether the user can view the sensor.
15
     *
16
     * @param  \App\User  $user
17
     * @return mixed
18
     */
19
    public function index(User $user)
20
    {
21
        return $user->isAdmin();
22
    }
23
    
24
    /**
25
     * Determine whether the user can view the create sensors page.
26
     *
27
     * @param  \App\User  $user
28
     * @return mixed
29
     */
30
    public function create(User $user)
31
    {
32
        return $user->isAdmin();
33
    }
34
    
35
    /**
36
     * Determine whether the user can create a sensor.
37
     *
38
     * @param  \App\User  $user
39
     * @return boolean
40
     */
41
    public function store(User $user)
42
    {
43
        return $user->isAdmin();
44
    }
45
    
46
    /**
47
     * Determine whether the user can view a sensor.
48
     *
49
     * @param  \App\User  $user
50
     * @return mixed
51
     */
52
    public function show(User $user)
53
    {
54
        return $user->isUser();
55
    }
56
    
57
    /**
58
     * Determine whether the user can view the edit page for a sensor.
59
     *
60
     * @param  \App\User  $user
61
     * @return mixed
62
     */
63
    public function edit(User $user)
64
    {
65
        return $user->isAdmin();
66
    }
67
    
68
    /**
69
     * Determine whether the user can update the sensor.
70
     *
71
     * @param  \App\User  $user
72
     * @return mixed
73
     */
74
    public function update(User $user)
75
    {
76
        return $user->isAdmin();
77
    }
78
    
79
    /**
80
     * Determine whether the user can delete the sensor.
81
     *
82
     * @param  \App\User  $user
83
     * @return mixed
84
     */
85
    public function destroy(User $user)
86
    {
87
        return $user->isAdmin();
88
    }
89
}
90

app/Policies/SitePolicy.php 1 location

@@ 9-89 (lines=81) @@
6
use App\Site;
7
use Illuminate\Auth\Access\HandlesAuthorization;
8
9
class SitePolicy
10
{
11
    use HandlesAuthorization;
12
    
13
    /**
14
     * Determine whether the user can view the site.
15
     *
16
     * @param  \App\User  $user
17
     * @return mixed
18
     */
19
    public function index(User $user)
20
    {
21
        return $user->isManager();
22
    }
23
    
24
    /**
25
     * Determine whether the user can view the create site page.
26
     *
27
     * @param  \App\User  $user
28
     * @return mixed
29
     */
30
    public function create(User $user)
31
    {
32
        return $user->isManager();
33
    }
34
    
35
    /**
36
     * Determine whether the user can create a site.
37
     *
38
     * @param  \App\User  $user
39
     * @return boolean
40
     */
41
    public function store(User $user)
42
    {
43
        return $user->isManager();
44
    }
45
    
46
    /**
47
     * Determine whether the user can view a site.
48
     *
49
     * @param  \App\User  $user
50
     * @return mixed
51
     */
52
    public function show(User $user)
53
    {
54
        return $user->isUser();
55
    }
56
    
57
    /**
58
     * Determine whether the user can view the edit page for a site.
59
     *
60
     * @param  \App\User  $user
61
     * @return mixed
62
     */
63
    public function edit(User $user)
64
    {
65
        return $user->isManager();
66
    }
67
    
68
    /**
69
     * Determine whether the user can update the site.
70
     *
71
     * @param  \App\User  $user
72
     * @return mixed
73
     */
74
    public function update(User $user)
75
    {
76
        return $user->isManager();
77
    }
78
    
79
    /**
80
     * Determine whether the user can delete the site.
81
     *
82
     * @param  \App\User  $user
83
     * @return mixed
84
     */
85
    public function destroy(User $user)
86
    {
87
        return $user->isManager();
88
    }
89
}
90