Exemple #1
0
 public function actionUpdateCars($id)
 {
     $car = ModelCars::findOne($id);
     $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->update();
     header("Location: http://" . $_SERVER['SERVER_NAME'] . "/cars/AllShowCars?id=" . $car->client_id);
 }
Exemple #2
0
 /**
  * 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.');
     }
 }
Exemple #3
0
 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];
 }