/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(PaiementRequest $request)
 {
     $validator = Validator::make($request->all(), ['type_carte' => 'required|alpha', 'numero_carte' => 'required|size:16|alpha_num', 'cryptogramme' => 'required|max:255|alpha_num']);
     if ($validator->fails()) {
         return redirect('post/create')->withErros($validator)->withInput();
     }
 }
示例#2
0
 /**
  * Create a new user
  *
  * https://laravel.com/docs/5.1/validation
  * @param  array $data
  * @return User
  */
 public static function create(array $attributes = [])
 {
     $table = with(new static())->table;
     //$v = self::validator($data);
     $v = Validator::make($attributes, static::$rules);
     $return = null;
     if ($v->passes()) {
         parent::create($attributes);
         $lastid = \DB::getpdo()->lastinsertid();
         $return = $lastid;
     } else {
         //$messages = $v->errors();
         $return = $v;
     }
     return $table;
 }
示例#3
0
 /**
  * Get a validator for an incoming registration request.
  *
  * @param  array  $data
  * @return \Illuminate\Contracts\Validation\Validator
  */
 protected function validator(array $data)
 {
     return Validator::make($data, ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
 }
示例#4
0
 /**
  * @param $value
  * @param $validator
  *
  * @return mixed
  * @throws \Exception
  */
 protected function createValidator($value, $validator)
 {
     $validator = Validator::make(['email' => '*****@*****.**', 'username' => 'kdadler'], ['email' => 'required|email|unique:users', 'username' => 'unique:users']);
     return $validator;
 }
 public function doLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:6');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to('/')->withErrors($validator)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $userdata = array('email' => Input::get('email'), 'password' => Input::get('password'));
         // attempt to do the login
         if (Auth::attempt($userdata)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // return Redirect::to('secure');
             // for now we'll just echo success (even though echoing in a controller is bad)
             echo 'SUCCESS!';
         } else {
             // validation not successful, send back to form
             return Redirect::to('/');
         }
     }
 }