ChecksPermissions   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 4
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hasPermissionTo() 0 5 2
A owns() 0 5 2
1
<?php
2
3
namespace Acacha\Events\Http\Requests\Traits;
4
use Auth;
5
6
/**
7
 * Trait ChecksPermissions.
8
 *
9
 * @package Acacha\Events\Http\Requests\Traits
10
 */
11
trait ChecksPermissions
12
{
13
    /**
14
     * Logged as permission to.
15
     *
16
     * @param $permission
17
     * @return bool
18
     */
19
    protected function hasPermissionTo($permission)
20
    {
21
        if (Auth::user()->hasPermissionTo($permission)) return true;
22
        return false;
23
    }
24
25
    /**
26
     * Owns model.
27
     *
28
     * @param $model
29
     * @return bool
30
     */
31
    protected function owns($model,$field = 'user_id')
32
    {
33
        if (Auth::user()->id == $this->$model->$field) return true;
34
        return false;
35
    }
36
}