Exemple #1
0
 /**
  * Delete this group from the database, along with any linked user and authorization rules
  *
  */
 public function delete()
 {
     // Remove all user associations
     $this->users()->detach();
     // Remove all group auth rules
     $auth_table = Database::getSchemaTable('authorize_group')->name;
     Capsule::table($auth_table)->where("group_id", $this->id)->delete();
     // Reassign any primary users to the current default primary group
     $default_primary_group = Group::where('is_default', GROUP_DEFAULT_PRIMARY)->first();
     $user_table = Database::getSchemaTable('user')->name;
     Capsule::table($user_table)->where('primary_group_id', $this->id)->update(["primary_group_id" => $default_primary_group->id]);
     // TODO: assign user to the default primary group as well?
     // Delete the group
     $result = parent::delete();
     return $result;
 }
Exemple #2
0
 /**
  * Delete this user from the database, along with any linked groups and authorization rules
  *
  * @return bool true if the deletion was successful, false otherwise.
  */
 public function delete()
 {
     // Remove all group associations
     $this->groups()->detach();
     // Remove all user auth rules
     $auth_table = Database::getSchemaTable('authorize_user')->name;
     Capsule::table($auth_table)->where("user_id", $this->id)->delete();
     // Remove all user events
     $event_table = Database::getSchemaTable('user_event')->name;
     Capsule::table($event_table)->where("user_id", $this->id)->delete();
     // Delete the user
     $result = parent::delete();
     return $result;
 }