| @@ 258-269 (lines=12) @@ | ||
| 255 | * |
|
| 256 | * @param mixed $role |
|
| 257 | */ |
|
| 258 | public function attachRole($role) |
|
| 259 | { |
|
| 260 | if (is_object($role)) { |
|
| 261 | $role = $role->getKey(); |
|
| 262 | } |
|
| 263 | ||
| 264 | if (is_array($role)) { |
|
| 265 | $role = $role['id']; |
|
| 266 | } |
|
| 267 | ||
| 268 | $this->roles()->attach($role); |
|
| 269 | } |
|
| 270 | ||
| 271 | /** |
|
| 272 | * Alias to eloquent many-to-many relation's detach() method. |
|
| @@ 276-287 (lines=12) @@ | ||
| 273 | * |
|
| 274 | * @param mixed $role |
|
| 275 | */ |
|
| 276 | public function detachRole($role) |
|
| 277 | { |
|
| 278 | if (is_object($role)) { |
|
| 279 | $role = $role->getKey(); |
|
| 280 | } |
|
| 281 | ||
| 282 | if (is_array($role)) { |
|
| 283 | $role = $role['id']; |
|
| 284 | } |
|
| 285 | ||
| 286 | $this->roles()->detach($role); |
|
| 287 | } |
|
| 288 | ||
| 289 | /** |
|
| 290 | * Attach multiple roles to a user |
|