Skip to content

Instantly share code, notes, and snippets.

@mateusgf
Last active December 20, 2015 06:49
Show Gist options
  • Save mateusgf/6089289 to your computer and use it in GitHub Desktop.
Save mateusgf/6089289 to your computer and use it in GitHub Desktop.
<?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