Merge branch 'faiqahzaman' of https://gitlab.com/azfararsyad/lelong into faiqahzaman
This commit is contained in:
@@ -36,31 +36,19 @@ class CartController extends Controller
|
|||||||
|
|
||||||
public function getCart($userid)
|
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()->toArray();
|
||||||
$lelongbid = LelongBid::where('id',$cart->lelongbid_id)->first();
|
$marhun = LelongBidMarhun::where('lelongbid_id','=',$lelongbid['id'])->get()->toArray();
|
||||||
$marhun = LelongBidMarhun::where('lelongbid_id','=',$lelongbid->id)->get();
|
|
||||||
$lelongbid->marhun = $marhun;
|
$carts[$index]['datalelongbid'] = $lelongbid;
|
||||||
$cart->lelongbid = $lelongbid;
|
$carts[$index]['datalelongbid']['lelongbidmarhun'] = $marhun;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sizeof($carts)!=0)
|
|
||||||
{
|
return response()->json($carts);
|
||||||
return response()->json([
|
|
||||||
'success' => true,
|
|
||||||
'carts' => $carts
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return response()->json([
|
|
||||||
'success' => false,
|
|
||||||
'message' => 'No Data',
|
|
||||||
], 401);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addToCart(Request $request)
|
public function addToCart(Request $request)
|
||||||
@@ -72,19 +60,9 @@ class CartController extends Controller
|
|||||||
|
|
||||||
if($item->save())
|
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([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'carts' => $carts
|
'carts' => $item
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Route;
|
|||||||
use App\Http\Controllers\AuthMobile\AuthController;
|
use App\Http\Controllers\AuthMobile\AuthController;
|
||||||
use App\Http\Controllers\AuthMobile\UserController;
|
use App\Http\Controllers\AuthMobile\UserController;
|
||||||
use App\Http\Controllers\AuthMobile\LelongMobileController;
|
use App\Http\Controllers\AuthMobile\LelongMobileController;
|
||||||
|
use App\Http\Controllers\CartController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user