i would like to get some help why ? i cant figure out why my ajax post request doesnt work when i move it into Repository to clean my Controller code
Laravel 5.5 Error code : 500
ajax call have _token header so problem should be not in ajax call
Working method in Controller :
public function postAjaxAddToCart(Request $request, $id, $size)
{
$product = Product::findOrFail($id);
$oldCart = Session::has("cart") ? Session::get("cart") : null;
$cart = new Cart($oldCart);
$cart->add($product, $product->id, $size);
$request->session()->put("cart", $cart);
}
doesnt works after move to Repository class:
public function postAjaxAddToCart(Request $request, $id, $size)
{
$this->productRepository->addToCardAjax($request, $id, $size);
}
repository method looks like:
public function addToCardAjax($request, $id, $size) {
$item = $this->model::findOrFail($id);
$oldCart = Session::has("cart") ? Session::get("cart") : null;
$cart = new Cart($oldCart);
$cart->add($item, $item->id, $size);
$request->session()->put("cart", $cart);
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2BLHMKn
via IFTTT
Aucun commentaire:
Enregistrer un commentaire