Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getCreateUser(){
- $config = array(
- 'pageName' => 'createUser',
- 'pageTitle' => 'Create User',
- 'formUrl' => action('UsersController@postCreateUser'),
- 'modelFields' => array(
- array('db_name' => 'employee_id', 'text' => 'Employee Id', 'mandatory' => TRUE),
- array('db_name' => 'full_name', 'text' => 'Full Name', 'mandatory' => TRUE),
- array('db_name' => 'email', 'text' => 'Email', 'mandatory' => FALSE),
- array('db_name' => 'password', 'text' => 'Password','value' => '12345', 'mandatory' => TRUE)
- ),
- 'submit_text' => 'Create'
- );
- return View::make('layouts.form', $config);
- }
- function postCreateUser(){
- $config = array(
- 'pageName' => 'createUser',
- 'pageTitle' => 'Create User',
- 'formUrl' => action('UsersController@postCreateUser'),
- 'modelFields' => array(
- array('db_name' => 'employee_id', 'text' => 'Employee Id', 'mandatory' => TRUE),
- array('db_name' => 'full_name', 'text' => 'Full Name', 'mandatory' => TRUE),
- array('db_name' => 'email', 'text' => 'Email', 'mandatory' => FALSE),
- array('db_name' => 'password', 'text' => 'Password','value' => '12345', 'mandatory' => TRUE)
- ),
- 'submit_text' => 'Create'
- );
- $validator = User::validate(Input::all());
- if($validator->passes()){
- $user = new User(Input::all());
- $user->password = Hash::make(Input::get('password'));
- $user->Company_id = '1';
- $user->save();
- Session::flash('message', 'User Created Successfully!');
- Session::flash('alert-class', 'alert-success');
- return View::make('layouts.form', $config);
- }
- return View::make('layouts.form', $config)->withErrors($validator->messages());
- }
- @if ( $errors->count() > 0 )
- <div class="alert alert-danger">
- <p>The following errors have occurred:</p>
- <ul>
- @foreach( $errors->all() as $message )
- <li>{{ $message }}</li>
- @endforeach
- </ul>
- </div>
- @endif
- @if(Session::has('message'))
- <p class="alert {{ Session::get('alert-class', 'alert-info') }} alert-dismissable"> {{ Session::get('message') }}</p>
- @endif
- function postCreateUser(){
- $validator = User::validate(Input::all());
- if($validator->passes()){
- $user = new User(Input::all());
- $user->password = Hash::make(Input::get('password'));
- $user->Company_id = '1';
- $user->save();
- Session::flash('message', 'User Created Successfully!');
- Session::flash('alert-class', 'alert-success');
- } else {
- Session::flash('message', Helpers::formatErrors($validator->messages()->all()));
- Session::flash('alert-class', 'alert-danger');
- }
- return Redirect::action('UsersController@getCreateUser');
- }
- Session::flash($key, $value);
- Session::push('flash.old', $key);
- Input::flashExcept('_token');
- Session::forget('_old_input');
- session()->now()
- View::make( 'view.name' )->withOldFormData( Input::all() );
- {{ Form::model( $old_form_data ) }}
Add Comment
Please, Sign In to add comment