Exemplo n.º 1
0
 /**
  * @expectedException \Cygnite\Validation\Exception\ValidatorException
  */
 public function testInputExceptionThrownOnIncorrectParameterPassed()
 {
     $input = Input::make();
     $v = Validator::create($input->post(), function ($v) {
         $v->addRule('foo', 'required|min:3|max:5')->addRule('bar', 'required|is_int')->addRule('something', 'phone|is_string')->addRule('baz', 'valid_email');
         return $v;
     });
     $this->assertFalse($v->run());
 }
 /**
  * Authenticate user and login into the system
  *
  */
 public function checkAction()
 {
     $input = Input::make();
     $post = $input->json();
     $crypt = new Encrypt();
     $credentials = array('email' => $post->email, 'password' => $crypt->encode($post->password));
     if ($this->auth->verify($credentials)) {
         $this->auth->login();
         $userInfo = $this->auth->userInfo();
         echo json_encode(array('success' => true, 'flash' => 'Logged In Successfully!!', 'name' => $userInfo['name']));
     } else {
         echo json_encode(array('success' => false, 'flash' => 'Invalid username or password', 'name' => ''));
     }
 }
Exemplo n.º 3
0
 private function __construct(Input $var)
 {
     if ($var instanceof Input) {
         $this->param = $var->post();
     }
 }
Exemplo n.º 4
0
 public function setUp()
 {
     $this->input = Input::make();
 }
 /**
  * Update a product
  *
  * @param $id
  */
 public function editAction($id)
 {
     $validator = null;
     $product = array();
     $product = Product::find($id);
     $form = new ProductForm($product, Url::segment(3));
     $form->action = 'edit';
     $input = Input::make();
     //Check is form posted
     if ($input->hasPost('btnSubmit') == true) {
         $validator = $this->setValidationRules($input);
         //Run validation
         if ($validator->run()) {
             // get post array value except the submit button
             $postArray = $input->except('btnSubmit')->post();
             $product->product_name = $postArray["product_name"];
             $product->category = $postArray["category"];
             $product->description = $postArray["description"];
             $product->validity = $postArray["validity"];
             $product->price = $postArray["price"];
             $product->created_at = $postArray["created_at"];
             $product->updated_at = $postArray["updated_at"];
             // Save form information
             if ($product->save()) {
                 $this->setFlash('success', 'Product updated successfully!')->redirectTo('product/index/' . Url::segment(3));
             } else {
                 $this->setFlash('error', 'Error occured while updating Product!')->redirectTo('product/index/' . Url::segment(3));
             }
         } else {
             //validation error here
             $form->errors = $validator->getErrors();
         }
         $form->validation = $validator;
     }
     $this->render('update', array('form' => $form->buildForm()->render(), 'validation_errors' => $form->errors, 'title' => 'Update the Product'));
 }