I have this template to create a new instance of my Poll model
{{ Form::model(new Poll, array('route' => 'create')) }}
{{ Form::label('topic', 'Topic:') }}
{{ Form::text('topic') }}
{{ Form::submit() }}
{{ Form::close() }}
This is the model
//models/Polls.php
class Poll extends Eloquent {}
This is the migration
//database/migrations/2014_03_16_182035_create_polls_table
class CreatePollsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::create('polls', function(Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('topic');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Schema::drop('polls');
}
}
What steps do I need to do know to build my object in the controller?
This is what I have, but when I post the form, it returns a 500 Status Code
//controllers/poll.php
class Poll extends BaseController {
public function index() {
return View::make('home');
}
public function create() {
$topic = Input::get('topic');
// if ($topic === "")
// return View::make('home');
$poll = Poll::create(array('topic' => $topic));
var_dump($poll);
return View::make('poll', array('poll' => $poll));
}