'Legacy'])->pluck('entity_id')->toArray(); $renter = AllowedLogin::where(['login_type' => 'Renter'])->pluck('entity_id')->toArray(); //Cycle through all of the users, and either update their role, or delete them. foreach($users as $user) { //Set the fail bit to false $failed = false; //Get the character information try { $character_info = $esi->invoke('get', '/characters/{character_id}/', [ 'character_id' => $user->character_id, ]); $corp_info = $esi->invoke('get', '/corporations/{corporation_id/', [ 'corporation_id' => $character_info->corporation_id, ]); } catch(RequestFailedException $e) { Log::warning('Failed to get character information in purge user command for user ' . $user->character_id); $failed = true; } //If the fail bit is still false, then continue if($failed === false) { //Get the user's role $role = UserRole::where(['character_id'])->first(); //Check if the user is allowed to login if(isset($corp_info->alliance_id)) { //Warped Intentions is allowed to login if($corp_info->alliance_id == '99004116') { //If the role is not Warped Intentions, then modify the role if($role != 'W4RP') { UserRole::where([ 'character_id' => $user->character_id, ])->update([ 'role' => 'W4RP', ]); } } else if(in_array($corp_info->alliance_id, $legacy)) { //Legacy Users if($role != 'Legacy') { UserRole::where([ 'character_id' => $user->character_id, ])->update([ 'role' => 'Legacy', ]); } } else if(in_array($corp_info->alliance_id, $renter)) { //Renter Users if($role != 'Renter') { UserRole::where([ 'character_id' => $user->character_id, ])->update([ 'role' => 'Renter', ]); } } else { //If the user is part of no valid login group, then delete the user. //Delete all of the permissions first UserPermission::where([ 'character_id' => $user->character_id, ])->delete(); //Delete the user's role UserRole::where([ 'character_id' => $user->character_id, ])->delete(); //Delete the user from the user table User::where([ 'character_id' => $user->character_id, ])->delete(); } } } } } }