Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     // echo "<pre/>";
     // print_r(Input::all());
     // exit();
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = array('name' => 'required', 'email' => 'required|email', 'nerd_level' => 'required|numeric', 'nerd_groups' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('nerds/create')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         // store
         $nerd = new Nerd();
         $nerd->name = Input::get('name');
         $nerd->email = Input::get('email');
         $nerd->nerd_level = Input::get('nerd_level');
         $nerd->save();
         $nerd->groups()->attach(Input::get('nerd_groups'));
         // redirect
         Session::flash('message', 'Successfully created nerd!');
         return Redirect::to('nerds');
     }
 }
Exemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // validate
     // read more on validation at http://laravel.com/docs/validation
     $rules = array('name' => 'required', 'email' => 'required|email', 'nerd_level' => 'required|numeric');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('nerds/create')->withErrors($validator);
     } else {
         // store
         $nerd = new Nerd();
         $nerd->name = Input::get('name');
         $nerd->email = Input::get('email');
         $nerd->nerd_level = Input::get('nerd_level');
         $nerd->save();
         // redirect
         Session::flash('message', 'Successfully created nerd!');
         return Redirect::to('nerds');
     }
 }