Skip to content

Commit

Permalink
Updated EntrustUserTrait since delete & restore methods are suppose…
Browse files Browse the repository at this point in the history
…d to return boolean
  • Loading branch information
Zizaco committed Nov 13, 2017
1 parent 9a6d32f commit 5a83c57
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/Entrust/Traits/EntrustUserTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

trait EntrustUserTrait
{
//Big block of caching functionality.
/**
* Big block of caching functionality.
*
* @return mixed Roles
*/
public function cachedRoles()
{
$userPrimaryKey = $this->primaryKey;
Expand All @@ -27,26 +31,40 @@ public function cachedRoles()
}
else return $this->roles()->get();
}

/**
* {@inheritDoc}
*/
public function save(array $options = [])
{ //both inserts and updates
if(Cache::getStore() instanceof TaggableStore) {
Cache::tags(Config::get('entrust.role_user_table'))->flush();
}
return parent::save($options);
}

/**
* {@inheritDoc}
*/
public function delete(array $options = [])
{ //soft or hard
parent::delete($options);
$result = parent::delete($options);
if(Cache::getStore() instanceof TaggableStore) {
Cache::tags(Config::get('entrust.role_user_table'))->flush();
}
return $result;
}

/**
* {@inheritDoc}
*/
public function restore()
{ //soft delete undo's
parent::restore();
$result = parent::restore();
if(Cache::getStore() instanceof TaggableStore) {
Cache::tags(Config::get('entrust.role_user_table'))->flush();
}
return $result;
}

/**
Expand Down

0 comments on commit 5a83c57

Please sign in to comment.