Last active
December 20, 2015 07:29
-
-
Save mateusgf/6093298 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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