Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Route::group(array('prefix' => 'account'), function(){
- Route::get('register', array(
- 'before' => 'guest',
- 'as' => 'account-create',
- 'uses' => 'AccountController@getCreate'
- ));
- Route::post('register', array(
- 'before' => 'guest|csrf',
- 'as' => 'account-create-post',
- 'uses' => 'AccountController@postCreate'
- ));
- Route::get('register/confirm', array(
- 'before' => 'guest',
- 'as' => 'account-create-confirm',
- 'uses' => 'AccountController@getCreateConfirm'
- ));
- Route::post('register/confirm', array(
- 'before' => 'guest|csrf',
- 'as' => 'account-create-confirm-post',
- 'uses' => 'AccountController@postCreateConfirm'
- ));
- Route::get('register/complete', array(
- 'before' => 'guest',
- 'as' => 'account-create-complete',
- 'uses' => 'AccountController@getCreateComplete'
- ));
- });
- <?php
- class AccountController extends BaseController {
- private $form_session = 'register_form';
- public function getCreate()
- {
- if(Session::has($this->form_session))
- {
- // get forms session data
- $data = Session::get($this->form_session);
- // clear forms session data
- Session::forget($this->form_session);
- // load the form view /w the session data as input
- return View::make('account.create')->with('input',$data);
- }
- return View::make('account.create');
- }
- public function postCreate()
- {
- // set the form input to the session
- Session::set($this->form_session, Input::all());
- $validation_rules = array(
- 'email' => 'required|max:50|email|unique:users',
- 'password' => 'required|max:60|min:6',
- 'password_conf' => 'required|max:60|same:password'
- );
- $validator = Validator::make(Input::all(), $validation_rules);
- // get forms session data
- $data = Session::get($this->form_session);
- // Return back to form w/ validation errors & session data as input
- if($validator->fails()) {
- return Redirect::back()->withErrors($validator);
- }
- // redirect to the confirm step
- return Redirect::route('account-create-confirm');
- }
- public function getCreateConfirm()
- {
- // prevent access without filling out step1
- if(!Session::has($this->form_session)) {
- return Redirect::route('account-create');
- }
- // get forms session data
- $data = Session::get($this->form_session);
- // retun the confirm view w/ session data as input
- return View::make('account.create-confirm')->with('input', $data);
- }
- public function postCreateConfirm()
- {
- $data = Session::get($this->form_session);
- // insert into DB
- // send emails
- // etc.
- // clear forms session data
- Session::forget($this->form_session);
- // redirect to the complete/success step
- return Redirect::route('account-create-complete');
- }
- public function getCreateComplete() {
- return View::make('account.create-complete');
- }
- }
- <form action="{{ URL::route('account-create-post') }}" method="post">
- Email: <input type="text" name="email" value="{{ (isset($input['email'])) ? e($input['email']) : '' }}">
- @if($errors->has('email'))
- {{ $errors->first('email') }}
- @endif
- <br />
- Password: <input type="text" name="password" value="">
- @if($errors->has('password'))
- {{ $errors->first('password') }}
- @endif
- <br />
- Password Confirm: <input type="text" name="password_conf" value="">
- @if($errors->has('password_conf'))
- {{ $errors->first('password_conf') }}
- @endif
- <br />
- {{ Form::token() }}
- <input type="submit" value="Confirm">
- </form>
- Email: {{ $input['email']; }}
- Password: {{ $input['password']; }}
- <form action="{{ URL::route('account-create-confirm-post') }}" method="post">
- {{ Form::token() }}
- <a href="{{ URL::previous() }}">return</a>
- <input type="submit" name="submit_forward" value="Submit">
- </form>
- Email: {{ $input['email'] }}
- Password: {{ $input['password'] }}
- <form action="{{ URL::route('account-create-confirm-post') }}" method="post">
- <input type="hidden" name="email" value="{{ $input['email'] }}">
- <input type="hidden" name="password" value="{{ $input['password'] }}">
- {{ Form::token() }}
- <a href="{{ URL::previous() }}">return</a>
- <input type="submit" name="submit_forward" value="Submit">
- </form>
- Email: {{ $input['email'] }}
- Password: {{ $input['password'] }}
- <form action="{{ URL::route('account-create-confirm-post') }}" method="post">
- <input type="hidden" name="id" value="{{ $user_id }}">
- {{ Form::token() }}
- <a href="{{ URL::previous() }}">return</a>
- <input type="submit" name="submit_forward" value="Submit">
- </form>
- public function getCreate() {
- if ($this->formRememberService->hasData()) {
- return View::make('account.create')
- ->with('input', $this->formRememberService->getData());
- }
- return View::make('account.create');
- }
- public function postCreate() {
- $this->formRememberService->saveData(Input::all());
- // ...
- }
- public function postCreateConfirm() {
- // ...
- $this->formRememberService->clear();
- return Redirect::route('account-create-complete');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement