5 use Illuminate\Database\Eloquent\Model;
7 class Role extends Model
10 * Sets the default role name for newly registed users.
13 protected static $default = 'viewer';
16 * The roles that belong to the role.
18 public function users()
20 return $this->belongsToMany('Oxbow\User');
24 * The permissions that belong to the role.
26 public function permissions()
28 return $this->belongsToMany('Oxbow\Permission');
32 * Add a permission to this role.
33 * @param Permission $permission
35 public function attachPermission(Permission $permission)
37 $this->permissions()->attach($permission->id);
41 * Get an instance of the default role.
44 public static function getDefault()
46 return static::where('name', '=', static::$default)->first();