/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $code = $request->input('code'); if (empty($code)) { return json_encode(array ( 'code' => 0, 'msg' => 'upload required code.' )); } $spec = $request->input('spec'); if (empty($spec)) { return json_encode(array ( 'code' => 0, 'msg' => 'upload required spec.' )); } $gaInfos = GoodAttribsInfo::where('acode', '=', $code) //->where('spec', '=', $spec) ->first(); if (empty($gaInfos)) { return json_encode(array ( 'code' => 0, 'msg' => 'Invalide code or spec.' )); } $request['gaInfos'] = $gaInfos; return $next($request); }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $goods = Good::orderBy('id', 'desc')->get(); $gid = empty($request->input('gid')) ? $goods[0]->id : $request->input('gid'); $goodInfos = array(); foreach ($goods as $key => $good) { $goodInfo = GoodAttribsInfo::where('gid', '=', $good->id) ->where('acode', '=', 'price') ->first(); $goodInfos[$key] = $goodInfo; } $data = array ( 'goods' => $goods, 'gid' => $gid, 'active' => 'active', 'goodInfos' => $goodInfos, 'is_select' => true, 'wTitle' => '购买临牌' ); return view('goods/detail', $data); }
/** * Show the application dashboard to the user. * * @return Response */ public function index(Request $request) { $goodDatas = Good::orderBy('id', 'desc')->get(); $goods = array(); $banners = Advertise::where('type', '=', 'index_banner') ->where('active', '=', 1) ->orderBy('seq', 'asc') ->get(); foreach ($goodDatas as $good) { $gInfo = GoodAttribsInfo::where('gid', '=', $good->id) ->where('acode', '=', 'price') ->first(); $good->price = $gInfo->value; array_push($goods, $good); } $homeGoodsDisplay = array(); foreach ($goods as $key => $good) { if (0 == $key % 2) { $homeGoodsDisplay[$key / 2] = array(); } $homeGoodsDisplay[$key / 2][] = $good; } ///// $goods = Good::orderBy('id', 'desc')->get(); $gid = empty($request->input('gid')) ? $goods[0]->id : $request->input('gid'); $goodInfos = array(); foreach ($goods as $key => $good) { $goodInfo = GoodAttribsInfo::where('gid', '=', $good->id) ->where('acode', '=', 'price') ->first(); $goodInfos[$key] = $goodInfo; } ///// return view('home', array( 'goods' => $goods, 'banners' => $banners, 'home' => 1, 'gid' => $gid, 'active' => 'active', 'goodInfos' => $goodInfos, 'is_select' => true, 'wTitle' => '51临牌网-您身边的车辆临时牌照专家' )); }
private function getGoodAttributesInfo ($gid) { $goodAttributes = GoodAttribsInfo::where('gid', '=', $gid)->get(); return $goodAttributes; }
public function getBuy(Request $request) { $gcode = $request->input('gcode'); $ch = $request->input('car_hand'); if (empty($ch) || strlen($ch) == 0) { return redirect('/miniorder/cartype'); } $user = Auth::user(); $gcode = (empty($gcode) || strlen($gcode) == 0) ? 'beyond-three' : $gcode; $good = Good::where('code', '=', $gcode)->first(); if (empty($good)) { //todo } $carhand = $ch == 1 ? 'one' : 'second'; $cars = Car::where('uid', '=', $user->id)->where('car_hand', '=', $carhand)->orderBy('last_used', 'desc')->get(); $defaultCar = Car::where('uid', '=', $user->id)->where('car_hand', '=', $carhand)->where('last_used', '=', 1)->first(); $receivers = Receiver::where('uid', '=', $user->id)->orderBy('last_used', 'desc')->get(); $defaultReceiver = Receiver::where('uid', '=', $user->id)->where('last_used', '=', 1)->first(); $bouns = Boun::where('uid', '=', $user->id) ->where('type', '=', 1) ->where('active', '=', 1) ->get(); $goodInfo = GoodAttribsInfo::where('gid', '=', $good->id)->where('acode', '=', 'price')->first(); $data = [ 'good' => $good, 'receivers' => $receivers, 'defaultReceiver' => $defaultReceiver, 'cars' => $cars, 'defaultCar' => $defaultCar, 'bouns' => $bouns, 'goodInfo' => $goodInfo, 'formCode' => md5(time()), 'car_hand' => $carhand, 'step' => 2, 'header' => '确认订单' ]; return view('mobile/pay', $data); }