Last active
December 20, 2015 06:49
-
-
Save mateusgf/6089289 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
<?php | |
class Questions_Controller extends Base_Controller { | |
public $restful = true; | |
public function __construct() { | |
$this->filter('before', 'auth')->only(array('create')); | |
} | |
public function get_index() { | |
return View::make('questions.index') | |
->with('title', 'Make It Snappy Q&A - Home'); | |
} | |
public function post_create() { | |
$validation = Question::validate(Input::all()); | |
if($validation->passes()) { | |
Question::create(array( | |
'question'=>Input::get('question'), | |
'user_id'=>Auth::user()->id | |
)); | |
return Redirect::to_route('home') | |
->with('message', 'Your question has been posted!'); | |
} else { | |
return Redirect::to_route('home')->with_errors($validation)->with_input(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment