tournasdim
8/20/2013 - 5:21 PM

L4 Authentication example (into the route.php)

L4 Authentication example (into the route.php)

<?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());
		}
	}
);