This commit is contained in:
Azfar Arsyad
2022-01-24 12:26:29 +08:00
parent 088c112d47
commit 5f4b357efd
2 changed files with 11 additions and 32 deletions
+10 -32
View File
@@ -36,31 +36,19 @@ class CartController extends Controller
public function getCart($userid)
{
$carts = Cart::where('user_id','=', $userid)->get();
$carts = Cart::where('user_id','=', $userid)->get()->toArray();
foreach($carts as $cart)
foreach($carts as $index => $cart)
{
$arraycart = [];
$lelongbid = LelongBid::where('id',$cart->lelongbid_id)->first();
$marhun = LelongBidMarhun::where('lelongbid_id','=',$lelongbid->id)->get();
$lelongbid->marhun = $marhun;
$cart->lelongbid = $lelongbid;
$lelongbid = LelongBid::where('id',$cart['lelongbid_id'])->first()->toArray();
$marhun = LelongBidMarhun::where('lelongbid_id','=',$lelongbid['id'])->get()->toArray();
$carts[$index]['datalelongbid'] = $lelongbid;
$carts[$index]['datalelongbid']['lelongbidmarhun'] = $marhun;
}
if(sizeof($carts)!=0)
{
return response()->json([
'success' => true,
'carts' => $carts
]);
}
else
{
return response()->json([
'success' => false,
'message' => 'No Data',
], 401);
}
return response()->json($carts);
}
public function addToCart(Request $request)
@@ -72,19 +60,9 @@ class CartController extends Controller
if($item->save())
{
$carts = Cart::where('user_id','=', $request->user_id)->get();
foreach($carts as $cart)
{
$arraycart = [];
$lelongbid = LelongBid::where('id',$cart->lelongbid_id)->first();
$marhun = LelongBidMarhun::where('lelongbid_id','=',$lelongbid->id)->get();
$lelongbid->marhun = $marhun;
$cart->lelongbid = $lelongbid;
}
return response()->json([
'success' => true,
'carts' => $carts
'carts' => $item
]);
}
else
+1
View File
@@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AuthMobile\AuthController;
use App\Http\Controllers\AuthMobile\UserController;
use App\Http\Controllers\AuthMobile\LelongMobileController;
use App\Http\Controllers\CartController;
/*
|--------------------------------------------------------------------------