public function themgioxe($id) { $xe = Cars::where('xe_id', $id)->get()->first(); $index = -1; if (Session::has('datxe')) { foreach (Session::get('datxe') as $key => $value) { //dd($key); die(); if ($id == Session::get('datxe')[$key]['id']) { $index = $key; break; } } if ($index === -1) { $item = array('id' => $id, 'name' => $xe->hang_xe . ' ' . $xe->ten_xe, 'socho' => $xe->socho_xe, 'color' => $xe->color, 'image' => $xe->url_hinhxe, 'bienso' => $xe->sodangky_xe, 'ngaysanxuat' => $xe->ngaysanxuat); //dd($item); Session::push('datxe', $item); } } else { $item = array('id' => $id, 'name' => $xe->hang_xe . ' ' . $xe->ten_xe, 'socho' => $xe->socho_xe, 'color' => $xe->color, 'image' => $xe->url_hinhxe, 'bienso' => $xe->sodangky_xe, 'ngaysanxuat' => $xe->ngaysanxuat); Session::push('datxe', $item); } return redirect('gioxe'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($xe_id) { $data = Cars::where('xe_id', $xe_id)->get()->first(); $brands = Brand::all(); $taixedaxepxe = Cars::select('tai_xe_id')->get(); foreach ($taixedaxepxe as $key => $taixe) { if ($taixe->tai_xe_id != null) { $taixearray[$key] = $taixe->tai_xe_id; } } $taixehientai = TaiXe::where('taixe_id', $data->tai_xe_id)->get()->first(); //dd($taixearray); $taixe = TaiXe::whereNotIN('taixe_id', $taixearray)->get(); //dd($taixe); return view('backend.cars.suaxe', compact('data', 'taixehientai', 'taixe', 'brands')); }