コード例 #1
0
ファイル: CarsController.php プロジェクト: quannh02/thuexeweb
 /**
  * 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'));
 }
コード例 #2
0
ファイル: CarsController.php プロジェクト: quannh02/thuexeweb
 public function getChiTiet($id)
 {
     $brands = $this->brands;
     $socho = $this->sochoxe;
     $tintucs = $this->tintucs;
     $binhluans = Comment::where('xe_id', $id)->orderBy('id', 'desc')->paginate(3);
     foreach ($binhluans as $key => $value) {
         if ($value->nguoidung_id != NULL) {
             $user = User::where('nguoidung_id', $value->nguoidung_id)->get()->first();
             $value->nguoidung_id = $user->tendaydu;
         }
     }
     //dd($binhluans);
     // xe hiện tại
     $xe = Cars::where('xe_id', $id)->get()->first();
     // tên lái xe theo xe
     $tenlaixe = TaiXe::where('taixe_id', $xe->tai_xe_id)->get()->first();
     $xekhac = Cars::whereNotIn('xe_id', [$id])->where(function ($query) use($xe) {
         $query->where('socho_xe', $xe->socho_xe)->orWhere('hang_id', $xe->hang_id);
     })->get();
     //dd($xekhac);
     //dd($xe); die();
     $vote_id = Vote::where('cars_id', $id)->get()->first();
     if ($vote_id->sovotes != 0) {
         $roundVote = round($vote_id->tongdiem / $vote_id->sovotes, 1);
     } else {
         $roundVote = 0;
     }
     //dd($vote_id);
     return view('frontend.pages.chitiet', compact('vote_id', 'binhluans', 'xe', 'socho', 'brands', 'tintucs', 'tenlaixe', 'xekhac', 'roundVote'));
 }
コード例 #3
0
 public function xoataixe($id)
 {
     $tai = TaiXe::findOrFail($id);
     $tai->delete();
     return redirect()->route('dstaixe');
 }