Test Setup Failed
Push — master ( 783348...69f7f6 )
by Php Easy Api
04:06
created

Role   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A roleMake() 0 17 4
1
<?php
2
3
namespace Resta\Role\Resource\Database;
4
5
use Illuminate\Database\Eloquent\Model as Eloquent;
6
7
class Role extends Eloquent
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $table = 'roles';
13
14
    /**
15
     * @param $role
16
     */
17
    public static function roleMake($role)
18
    {
19
        $roleCriteria = explode(':',$role);
20
        
21
        if(isset($roleCriteria[1])){
22
            $role = static::where('name',$roleCriteria[0])->
23
            where('status',1)->where('is_deleted',0)->where('role_state',$roleCriteria[1])->first();
24
            
25
            if(is_null($role)){
26
                exception('roleDefinitorException')->runtime('roleDefinitorException');
27
            }
28
            
29
            if(auth()->user()->role_id == $role->id){
30
                return true;
31
            }
32
            
33
            return false;
34
        }
35
        
36
    }
37
}
38
39