public function delete($id)
 {
     $msg = MessageModel::id($id);
     if (!empty($msg->report)) {
         @unlink(path($msg->report));
     }
     Response::json(MessageModel::delete('id = ?', [$id]));
 }
Beispiel #2
0
 public function delete()
 {
     $user = User::getData();
     if (!empty($user->avatar)) {
         @unlink(Url::resource($user->avatar));
     }
     $userFlag = UserModel::delete('id = ?', [$user->id]);
     $perFlag = PermissionModel::delete('user_id = ?', [$user->id]);
     $msgFlag = MessageModel::delete('user_id = ?', [$user->id]);
     $compFlag = ComplainModel::delete('user_id = ?', [$user->id]);
     $status = $userFlag && $perFlag && $msgFlag && $compFlag;
     if ($status) {
         $u = new User();
         $u->logout();
     }
     Response::json(['status' => $status]);
 }
Beispiel #3
0
 public function delete($id)
 {
     $current = User::getData();
     $admin = PermissionModel::findBy(['user_id' => $current->id, 'permission' => 'admin']);
     $userFlag = $perFlag = $msgFlag = $compFlag = FALSE;
     if ($current->id != $id && $admin) {
         $avatar = UserModel::id($id)->avatar;
         if (!empty($avatar)) {
             @unlink(Url::resource($avatar));
         }
         $userFlag = UserModel::delete('id = ?', [$id]);
         $perFlag = PermissionModel::delete('user_id = ?', [$id]);
         $msgFlag = MessageModel::delete('user_id = ?', [$id]);
         $compFlag = ComplainModel::delete('user_id = ?', [$id]);
     }
     Response::json(['status' => $userFlag && $perFlag && $msgFlag && $compFlag]);
 }