Passed
Push — master ( 0f5478...69af09 )
by Ion
04:44
created

RolePermission   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 32
c 1
b 0
f 1
dl 0
loc 73
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A permission() 0 3 1
A role() 0 3 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Relations\BelongsTo;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
/**
9
 * Class RolePermission
10
 *
11
 * @package App\Models
12
 */
13
class RolePermission extends Model
14
{
15
    use SoftDeletes;
16
17
    /** @var int */
18
    const PERMISSION_FALSE = 0;
19
20
    /** @var int */
21
    const PERMISSION_TRUE = 1;
22
23
    /** @var int */
24
    const MANAGE_OWN = 0;
25
26
    /** @var int */
27
    const MANAGE_ALL = 1;
28
29
    /** @var bool */
30
    public $timestamps = true;
31
32
    /** @var string */
33
    protected $table = 'role_permissions';
34
35
    /** @var array */
36
    protected $fillable = [
37
        'role_id',
38
        'permission_id',
39
        'read',
40
        'create',
41
        'update',
42
        'delete',
43
        'manage'
44
    ];
45
46
    /** @var array */
47
    protected $visible = [
48
        'id',
49
        'role_id',
50
        'permission_id',
51
        'read',
52
        'create',
53
        'update',
54
        'delete',
55
        'manage',
56
        'role',
57
        'permission'
58
    ];
59
60
    /** @var array */
61
    protected $sortable = [
62
        'id'
63
    ];
64
65
    /** @var array */
66
    protected $searchable = [];
67
68
    /**
69
     * Role.
70
     *
71
     * @return BelongsTo
72
     */
73
    public function role()
74
    {
75
        return $this->belongsTo(Role::class, 'role_id', 'id');
76
    }
77
78
    /**
79
     * Permission.
80
     *
81
     * @return BelongsTo
82
     */
83
    public function permission()
84
    {
85
        return $this->belongsTo(Permission::class, 'permission_id', 'id');
86
    }
87
}
88