Reputation: 15
HERE i am trying to make REST API's using the mentioned package but it doesn't seems working with API Can you point out if i am making mistake.
class CartController extends Controller
{
public function ShowCart(){
$content = Cart::content();
return response()->json(['success'=>'true','item-list'=>$content]);
}
public function AddItemToCart(Request $request,$id){
$item = FoodItem::where('id',$id)->first();
Cart::add($item->id,$item->item_name,1,$item->price, ['image' => $request->image ,
'extras' =>$request->extras,'attribute'=>$request->attributes,]);
return response()->json(['success'=>'true']);
}
public function AddQuantity($rowId){
$row = Cart::get($rowId);
Cart::update($rowId, $row->qty +1);
return response()->json(['success'=>'true']);
}
public function SubstractQuantity($rowId){
$row = Cart::get($rowId);
Cart::update($rowId,$row->qty - 1);
return response()->json(['success'=>'true']);
}
public function DiscardCart(){
Cart::destroy();
return response()->json(['success'=>'true']);
}
}
Upvotes: 0
Views: 383
Reputation: 25
Your package is working with session and not a database. As far as I understand what you are trying to do, I would not use this package to make an API.
Upvotes: 1