public function store()
{
// Validate the Input data.
$input = Input::only('username', 'role', 'realname', 'password', 'password_confirmation', 'email');
$validator = $this->validate($input);
if ($validator->passes()) {
// Encrypt the given Password.
$password = Hash::make($input['password']);
// Create a User Model instance.
User::create(array('username' => $input['username'], 'password' => $password, 'role_id' => $input['role'], 'realname' => $input['realname'], 'email' => $input['email'], 'active' => 1));
// Prepare the flash message.
$status = __d('users', 'The User <b>{0}</b> was successfully created.', $input['username']);
return Redirect::to('admin/users')->withStatus($status);
}
// Errors occurred on Validation.
$status = $validator->errors();
return Redirect::back()->withInput()->withStatus($status, 'danger');
}