Fix user deletion
This commit is contained in:
parent
397172de3b
commit
054e65b78f
1 changed files with 9 additions and 4 deletions
|
@ -165,7 +165,7 @@ class UserRepository
|
||||||
*/
|
*/
|
||||||
public function delete($id)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
if (Models\Server::where('owner', $id)->count() > 0) {
|
if (Models\Server::where('owner_id', $id)->count() > 0) {
|
||||||
throw new DisplayException('Cannot delete a user with active servers attached to thier account.');
|
throw new DisplayException('Cannot delete a user with active servers attached to thier account.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,10 +177,15 @@ class UserRepository
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Models\Permission::where('user_id', $id)->delete();
|
foreach(Models\Subuser::with('permissions')->where('user_id', $id)->get() as &$subuser) {
|
||||||
Models\Subuser::where('user_id', $id)->delete();
|
foreach($subuser->permissions as &$permission) {
|
||||||
Models\User::destroy($id);
|
$permission->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
$subuser->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
Models\User::destroy($id);
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue