public function __construct() { $this->brands = Brand::all(); $this->sochoxe = Cars::select('socho_xe')->distinct()->orderBy('socho_xe', 'asc')->get(); $this->tintucs = TinTuc::select('id', 'tieude', 'noidung')->orderBy('id', 'desc')->take(5)->get(); }
/** * 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')); }