-1

My table does not have a primary key.I want to use userId and cartId together.

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;
    }
}

Should I define 2 column as primary? how?

d.k
  • 147
  • 1
  • 4
  • 15

2 Answers2

0

Please update your deleteNote()

public function deleteNote($uyeid,$cartId){

    $this->repo->getUserCart($cartId)->delete();
}
0

Change this line in getUserCart() function:

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

into

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

//OR

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

The error occur in where clause. So change it and I hope it would helpful.

Inzamam Idrees
  • 1,955
  • 14
  • 28