Skip to content

Instantly share code, notes, and snippets.

@mateusgf
Last active December 20, 2015 07:29
Show Gist options
  • Save mateusgf/6093298 to your computer and use it in GitHub Desktop.
Save mateusgf/6093298 to your computer and use it in GitHub Desktop.
// Adiciona o update na autenticacao!
public function __construct() {
$this->filter('before', 'auth')->only(array('create', 'your_questions', 'edit', 'update'));
}
public function put_update() {
$id = Input::get('question_id');
if (!$this->question_belongs_to_user($id)) {
return Redirect::to_route('your_questions')->with('message', 'Invalid Question');
}
$validation = Question::validate(Input::all());
if ($validation->passes()) {
Question::update($id, array(
'question'=>Input::get('question'),
'solved'=>Input::get('solved')
));
return Redirect::to_route('question', $id)
->with('message', 'Your question has been updated!');
} else {
return Redirect::to_route('edit_question', $id)->with_errors($validation);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment