Last active
December 20, 2015 07:28
-
-
Save mateusgf/6093179 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
// Nossa ação de editar também deve ser protegida! | |
public function __construct() { | |
$this->filter('before', 'auth')->only(array('create', 'your_questions', 'edit')); | |
} | |
public function get_edit($id = NULL) { | |
if (!$this->question_belongs_to_user($id)) { | |
return Redirect::to_route('your_questions')->with('message', 'Invalid Question'); | |
} | |
return View::make('questions.edit') | |
->with('title', 'Make It Snappy Q&A - Edit') | |
->with('question', Question::find($id)); | |
} | |
private function question_belongs_to_user($id) { | |
$question = Question::find($id); | |
if ($question->user_id == Auth::user()->id) { | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment