Last active
December 21, 2015 09:19
-
-
Save tournasdim/6284453 to your computer and use it in GitHub Desktop.
L4 Authentication example (into the route.php)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Laravel 4 Validation example | |
Route::post('register', function() { | |
$rules = array( | |
'name' => 'required|min:3|max:80|alpha_dash', | |
'email' => 'required|between:3,64|email|unique:users', | |
'password' => 'required|alpha_num|between:4,8|confirmed', | |
'password_confirmation' => 'required|alpha_num|between:4,8' | |
); | |
$validator = Validator::make(Input::all(), $rules); | |
if ($validator->passes()) { | |
User::create(array( | |
'name' => Input::get('name'), | |
'email' => Input::get('email'), | |
'password' => Hash::make(Input::get('password')) | |
)); | |
return Redirect::to('/')->with('message','Thanks for registering!'); | |
} else { | |
return Redirect::to('/')->withErrors($validator->getMessages()); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment