Exemplo n.º 1
0
 /**
  * post_index validates input for the new critt and creates the critt in the DB
  */
 public function post_index()
 {
     // get filtered input for the critt
     $new_critt = array('critt' => htmlspecialchars(Input::get('new_critt')));
     // assign validation rules
     $rules = array('critt' => 'required|min:3|max:321');
     // Make the validator
     $validation = Validator::make($new_critt, $rules);
     if ($validation->fails()) {
         return Redirect::to_action('user@index')->with('user', Auth::User())->with_errors($validation)->with_input();
     }
     // attach current user's ID to the user_id in critts table
     $new_critt['user_id'] = Auth::user()->id;
     // create the new critt and get back to the user's profile
     $critt = new Critt($new_critt);
     $critt->save();
     return Redirect::to_action('user@index');
 }