Open AbdullahKaram-Dev opened 12 months ago
i find this way with that pretty package thank you very much but is that the right way i need advice ?
/**
* @throws InvalidAssociatedException
* @throws InvalidModelException
*/
public function destroy(Template $template, Cart $cart): JsonResponse
{
if ($template->hasInCart('soni-designer')) {
$itemHash = $cart->name('soni-designer')->getDetails()->get('items')->filter(function ($item) use ($template) {
return $item->model->id === $template->getAttribute('id');
})->first()->get('hash');
$cart->name('soni-designer')->removeItem($itemHash);
}
return $this->responseJson([
'success' => true,
'cart' => $cart->name('soni-designer')->getDetails(withActions: false, withTaxes: false),
]);
}
in case i have model id how i can get hashItem related to this model to destory it