Esempio n. 1
0
 public function restore()
 {
     //soft delete undo's
     parent::restore();
     if (Cache::getStore() instanceof TaggableStore) {
         Cache::tags(Config::get('entrust.role_user_table'))->flush();
     }
 }
 public function restore()
 {
     //soft delete undo's
     if (!parent::restore()) {
         return false;
     }
     if (Cache::getStore() instanceof TaggableStore) {
         Cache::tags(Config::get('entrust.permission_role_table'))->flush();
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Boot the user model
  * Attach event listener to remove the many-to-many records when trying to delete
  * Will NOT delete any records if the user model uses soft deletes.
  *
  * @return void|bool
  */
 public static function bootEntrustUserTrait()
 {
     $flushCache = function () {
         if (Cache::getStore() instanceof TaggableStore) {
             Cache::tags(Config::get('entrust.permission_role_table'))->flush();
         }
     };
     static::restored($flushCache);
     static::deleted($flushCache);
     static::saved($flushCache);
     static::deleting(function ($user) {
         if (!method_exists(Config::get('auth.model'), 'bootSoftDeletes')) {
             $user->roles()->sync([]);
         }
         return true;
     });
 }
Esempio n. 4
0
 /**
  * Flush the cached roles when new cache is restored
  * restore = undo soft deleting
  */
 public function restore()
 {
     parent::restore();
     if (Cache::getStore() instanceof TaggableStore) {
         Cache::tags($this->cacheName)->flush();
     }
 }
Esempio n. 5
0
 /**
  * Save the inputted permissions.
  *
  * @param mixed $inputPermissions
  *
  * @return void
  */
 public function savePermissions($inputPermissions)
 {
     if (!empty($inputPermissions)) {
         $this->perms()->sync($inputPermissions);
     } else {
         $this->perms()->detach();
     }
     if (Cache::getStore() instanceof TaggableStore) {
         Cache::tags(Config::get('entrust.permission_role_table'))->flush();
     }
 }
Esempio n. 6
0
 /**
  * Check if tag caching is allowed
  *
  * @return bool
  */
 public function isTagCacheAllowed()
 {
     return Cache::getStore() instanceof TaggableStore;
 }