Ejemplo n.º 1
0
 public function postShowAdd()
 {
     if (!$this->signer->validateSignature($_POST['_token'])) {
         header('HTTP/1.0 400 Bad Request');
         exit;
     }
     $validation_data = ['title' => 'min:3|max:30', 'testimonial' => 'min:10|max:5000'];
     // validate data
     $validator = new Validator();
     $errors = $validator->isValid($validation_data);
     // if validation fails, go back to register
     // page and display error message
     if (sizeof($errors) > 0) {
         $_SESSION['msg'] = $errors;
         echo $this->blade->render('add-testimonial', ['signer' => $this->signer]);
         unset($_SESSION['msg']);
         exit;
     }
     $testimonial = new Testimonial();
     $testimonial->title = $_REQUEST['title'];
     $testimonial->testimonial = $_REQUEST['testimonial'];
     $testimonial->user_id = LoggedIn::user()->id;
     $testimonial->save();
     header("Location: /testimonial-saved");
     exit;
 }
 /**
  * Handle new posted testmonial
  */
 public function postShowAdd()
 {
     $rules = ['title' => 'min:3', 'testimonial' => 'min:10'];
     $validator = new Validator($this->request, $this->response);
     $valid = $validator->validate($rules, '/add-testimonial');
     if ($valid) {
         $testimonial = new Testimonial();
         $testimonial->title = $this->request->input('title');
         $testimonial->testimonial = $this->request->input('testimonial');
         $testimonial->user_id = LoggedIn::user()->id;
         $testimonial->save();
         $this->response->redirectTo('/testimonial-saved');
     }
 }
Ejemplo n.º 3
0
 public function postShowAdd()
 {
     $validation_data = ['title' => 'min:3', 'testimonial' => 'min:10'];
     // validate the data
     $validator = new Validator();
     $errors = $validator->isValid($validation_data);
     // if validation fails go back to register
     // page and display error message
     if (sizeof($errors) > 0) {
         $_SESSION['msg'] = $errors;
         echo $this->blade->render('add-testimonial');
         unset($_SESSION['msg']);
         exit;
     }
     $testimonial = new Testimonial();
     $testimonial->title = $_REQUEST['title'];
     $testimonial->testimonial = $_REQUEST['testimonial'];
     $testimonial->user_id = LoggedIn::user()->id;
     $testimonial->save();
     header("Location: /testimonial-saved");
 }
Ejemplo n.º 4
0
 public function postShowAdd()
 {
     $errors = [];
     $validation_data = ["title" => "min:3", "testimonial" => "min:10"];
     //validate
     $validator = new Validator();
     $errors = $validator->isValid($validation_data);
     // if validation fails display error message
     if (sizeof($errors) > 0) {
         $_SESSION['msg'] = $errors;
         echo $this->blade->render('add-testimonial');
         unset($_SESSION['msg']);
         exit;
     }
     $testimonial = new Testimonial();
     $testimonial->title = $_REQUEST['title'];
     $testimonial->testimonial = $_REQUEST['testimonial'];
     $testimonial->user_id = LoggedIn::user()->id;
     $testimonial->save();
     header("Location: /testimonial-saved");
     exit;
 }