Exemplo n.º 1
0
 function add($request, $response, $args)
 {
     $body = $request->getParsedBody();
     //var_dump($body);
     $skill = new Skills();
     $skill->title = $body['title'];
     $skill->started = $body['date'];
     $skill->save();
     //echo "skills add";
 }
Exemplo n.º 2
0
 function add($request, $response, $args)
 {
     $error = [];
     $success = false;
     $body = $request->getParsedBody();
     $body['dateStarted'] = $this->formatDate($body['dateStarted']);
     $body['dateFinished'] = $this->formatDate($body['dateFinished']);
     //        var_dump($body);
     //
     //        die;
     if (!isset($body['stillUsing'])) {
         $body['stillUsing'] = false;
     }
     $skill = new Skills();
     $result = $skill::where('title', $body['title'])->first();
     if ($result) {
         if ($body['title'] !== $result->title) {
             $skill->title = $body['title'];
             $skill->dateStarted = $body['dateStarted'];
             $skill->dateFinished = $body['dateFinished'];
             $skill->stillUsing = $body['stillUsing'];
             $skill->save();
             $success = true;
         } else {
             $error['duplicate'] = $body['title'] . " is already present";
         }
     } else {
         $skill->title = $body['title'];
         $skill->dateStarted = $body['dateStarted'];
         $skill->dateFinished = $body['dateFinished'];
         $skill->stillUsing = $body['stillUsing'];
         $skill->save();
         $success = true;
     }
     $return['skills'] = $skill::all()->toArray();
     $return['error'] = $error;
     $return['success'] = $success;
     return $return;
     //echo "skills add";
 }
Exemplo n.º 3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Skills();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Skills'])) {
         $model->attributes = $_POST['Skills'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }