public function run() { if (false == $this->verifyUserAuth()) { return false; } $id = $this->getDataItem('id'); $userId = $this->getUserAuth()->userId; $status = BpFavorites::find("bp_id = {$id} and user_id = {$userId}")->delete(); if ($status) { $this->setResult(['success' => 1, 'message' => '删除成功!']); } else { $this->setResult(['success' => 0, 'message' => '删除失败!']); } }
public function run() { if (false == $this->verifyUserAuth()) { return false; } $id = $this->getDataItem('id'); $userId = $this->getUserAuth()->userId; $bp = BpFavorites::find(["where" => "bp_id = " . $id . " and user_id =" . $userId]); if ($bp->toArray()) { $stauts = $bp->delete(); if ($stauts) { $this->setResult(['success' => 1, 'message' => '取消成功!']); } else { $this->setResult(['success' => 0, 'message' => '取消失败!']); } } else { $this->setResult(['success' => 0, 'message' => '取消失败!']); } }