Completed
Pull Request — master (#10)
by
unknown
01:47
created

Role::permissions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Microboard\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
7
use Illuminate\Database\Eloquent\Relations\HasMany;
8
9
class Role extends Model
10
{
11
    /**
12
     * The attributes that are mass assignable.
13
     *
14
     * @var array
15
     */
16
    protected $fillable = [
17
        'name', 'display_name'
18
    ];
19
20
    /**
21
     * The relations to eager load on every query.
22
     *
23
     * @var array
24
     */
25
    protected $with = [
26
        'permissions'
27
    ];
28
29
    /**
30
     * @return HasMany
31
     */
32
    public function users()
33
    {
34
        return $this->hasMany(config('microboard.roles.user', User::class));
35
    }
36
37
    /**
38
     * @return BelongsToMany
39
     */
40
    public function permissions()
41
    {
42
        return $this->belongsToMany(Permission::class);
43
    }
44
}
45