-1

我的表没有主键。我想同时使用 userIdcartId

public function delete($uyeid,$Id){

    $this->getCart($Id)->delete();
}

 public function getCart($Id){
    try {
       $data = getCart::whereCartId($Id)->get();

        return $data;
    } catch(\Exception $e){
        return null;
    }
}

我应该将 2 列定义为主要列吗?如何?

4

2 回答 2

0

在getUserCart()函数中更改此行:

$data = getUserCart::whereCartId($cartId)->firstOrFail();

进入

$data = getUserCart::find($cartId);

//OR

$data = getUserCart::where('CartId',$cartId)->firstOrFail();

错误发生在where子句中。所以改变它,我希望它会有所帮助。

于 2019-01-08T11:17:23.653 回答
0

请更新您的deleteNote()

public function deleteNote($uyeid,$cartId){

    $this->repo->getUserCart($cartId)->delete();
}
于 2019-01-08T10:52:26.553 回答