| 1 | <?php |
||
| 7 | trait RefreshesPermissionCache |
||
| 8 | { |
||
| 9 | public static function bootRefreshesPermissionCache() |
||
| 10 | { |
||
| 11 | static::created(function ($model) { |
||
| 12 | $model->forgetCachedPermissions(); |
||
| 13 | }); |
||
| 14 | |||
| 15 | static::updated(function ($model) { |
||
| 16 | $model->forgetCachedPermissions(); |
||
| 17 | }); |
||
| 18 | |||
| 19 | static::deleted(function ($model) { |
||
| 20 | $model->forgetCachedPermissions(); |
||
| 21 | }); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Forget the cached permissions. |
||
| 26 | */ |
||
| 27 | public function forgetCachedPermissions() |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Get the current cached permissions. |
||
| 34 | * |
||
| 35 | * @return \Illuminate\Database\Eloquent\Collection |
||
| 36 | */ |
||
| 37 | protected static function getPermissions() |
||
| 41 | } |
||
| 42 |