public function actionAddCars() { $car = new ModelCars(); $car->auto_marka = $_POST['auto_marka']; $car->auto_model = $_POST['auto_model']; $car->year = $_POST['year']; $car->volume = $_POST['volume']; $car->power = $_POST['power']; $car->GUR = $_POST['gur']; $car->ABS = $_POST['abs']; $car->VIN = $_POST['vin']; $car->client_id = $_POST['client_id_hidden']; $car->data_a = date('Y-m-d H:i:s'); $car->insert(); header("Location: http://" . $_SERVER['SERVER_NAME'] . "/cars/AllShowCars?id=" . $_POST['client_id_hidden']); }
public function actionAllShowCars() { // связь таблиц clients и cars по id(clients) и client_id(cars) $id = $_GET['id']; $field = 'client_id'; $this->view->items = Model::findAllUserId($id, $field); $this->view->display('cars_client'); }
/** * Run the database seeds. * * @return void */ public function run() { $json = File::get(storage_path() . '/jsondata/cars.json'); $data = json_decode($json); // dd($data); die(); foreach ($data as $obj) { Cars::create(array('id' => $obj->id, 'car_type_id' => $obj->car_type_id, 'price_id' => $obj->price_id, 'image' => $obj->image, 'registration_number' => $obj->registration_number, 'color' => $obj->color, 'NgaySX' => $obj->NgaySX)); } }
/** * @return \yii\db\ActiveQuery */ public function getCar() { return $this->hasOne(Cars::className(), ['id' => 'car_id']); }
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'); }
/** * Finds the Cars model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Cars the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Cars::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function delete($id) { $car = Cars::findOrFail($id); $car_in_don_dat = DonDatCT::where('xe_id', $id)->count(); dd($car_in_don_dat); die; $car->delete(); return redirect()->route('danhsachxe'); }
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(); }
public function compensation(Request $request) { $crews = Cars::orderBy('code')->get(['gn', 'id', 'code']); $shifts = json_decode($this->getShifts(), true); $compensations = DB::table('compensation')->where('end', '=', '0')->get(['*']); $user_logs = DB::table('users_logs')->where('event', '=', 'compensation')->where('city', '=', $this->city->index)->orderBy('id', 'desc')->take(30)->get(['descr', 'date']); return view('personal.compensation', ['crews' => $crews, 'shifts' => $shifts, 'compensations' => $compensations, 'user_logs' => $user_logs]); }
public function actionGetCarPhotos($carId) { $carId = substr($carId, 7); $auto = Cars::findOne($carId); $carName = $auto->name; $photos = $auto->photos; $html = ''; for ($i = 0; $i < count($photos); $i++) { if ($i == 0) { $dots = '<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>'; } else { $dots .= '<li data-target="#carousel-example-generic" data-slide-to="' . $i . '" class=""></li>'; } } $desc = '<p>' . $auto->description . '</p>'; foreach ($photos as $photo) { if ($html == '') { $html .= '<div class="item active"><img class="img-responsive" src="' . Url::to('@web/src/upload/') . $photo->url . '"></div>'; } else { $html .= '<div class="item"><img class="img-responsive" src="' . Url::to('@web/src/upload/') . $photo->url . '"></div>'; } } Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ['result' => $html, 'p' => $desc, 'dots' => $dots, 'carName' => $carName]; }