]> BookStack Code Mirror - bookstack/blob - app/Role.php
Improved empty lists. Fixes #10.
[bookstack] / app / Role.php
1 <?php
2
3 namespace Oxbow;
4
5 use Illuminate\Database\Eloquent\Model;
6
7 class Role extends Model
8 {
9     /**
10      * The roles that belong to the role.
11      */
12     public function users()
13     {
14         return $this->belongsToMany('Oxbow\User');
15     }
16
17     /**
18      * The permissions that belong to the role.
19      */
20     public function permissions()
21     {
22         return $this->belongsToMany('Oxbow\Permission');
23     }
24
25     /**
26      * Add a permission to this role.
27      * @param Permission $permission
28      */
29     public function attachPermission(Permission $permission)
30     {
31         $this->permissions()->attach($permission->id);
32     }
33
34 }