예제 #1
0
 public function post_index()
 {
     $new = new Cars();
     $new->save();
     $response = array('success' => true, 'data' => array('id' => $new->id));
     $json = json_encode($response);
     return $json;
 }
예제 #2
0
 public function action_index()
 {
     $record = new Cars();
     $record->manufacturer = $_POST['manufacturer'];
     $record->model = $_POST['model'];
     $record->year = $_POST['year'];
     $record->save();
     $array = array('success' => 'true', 'msg' => 'Record added successfully');
     $json = json_encode($array);
     return $json;
 }
예제 #3
0
 public function action_index()
 {
     $record = new Cars();
     $record->parent_id = $_POST['parent_id'];
     $record->text = $_POST['text'];
     $record->leaf = $_POST['leaf'];
     $record->save();
     $array = array('success' => 'true', 'msg' => 'Record added successfully');
     $json = json_encode($array);
     return $json;
 }
예제 #4
0
 public function post_index()
 {
     $data = file_get_contents('php://input');
     $temp = json_decode($data);
     $new = new Cars();
     $new->text = $temp->text;
     $new->parent_id = $temp->parentId;
     $new->leaf = $temp->leaf;
     $new->save();
     $response = array('success' => true, 'data' => array('id' => $new->id));
     $json = json_encode($response);
     return $json;
 }
 public function actionCreateCar()
 {
     $model = new Cars();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Cars'])) {
         $model->attributes = $_POST['Cars'];
         $model->ower_id = Yii::app()->user->id;
         if ($model->save()) {
             Yii::app()->user->setFlash('addsuccess', '添加成功');
         }
         //				$this->redirect(array('view','id'=>$model->id));
     }
     $this->render('car_create', array('model' => $model));
 }
 public function saveNewCar()
 {
     $name = Input::get('name');
     $brand = Input::get('brand');
     $model = Input::get('model');
     $registration = Input::get('registration');
     $policeNumber = Input::get('police_number');
     $uberNumber = Input::get('uber_number');
     try {
         $user = new Cars();
         $user->name = $name;
         $user->brand = $brand;
         $user->model = $model;
         $user->registration = $registration;
         $user->police_number = $policeNumber;
         $user->uber_number = $uberNumber;
         $user->save();
         $result = array('success' => true);
     } catch (Exception $ex) {
         \Log::error(__METHOD__ . ' | error :' . print_r($ex, 1));
         $result = array('success' => false);
     }
     return $result;
 }