I have created a model named, Author. I tried creating a model with the help of eloquent create method like this:
public function postCreate(){
Author::create(array(
'user' => Input::get('user'),
'info' => Input::get('info')
));
return Redirect::to('authors')
->with('message', 'User created successfully');
}
'user' and 'info' are the name of the form elements. I am sure I am not mistaken with typo. When I run this, models is not created and says MassAssignmentException.
But when I tried with the following method, the model is created and was saved in the table
public function postCreate(){
$author = new Author;
$author->name = Input::get('user');
$author->info= Input::get('info');
$author->save();
return Redirect::to('authors')
->with('message', 'User created successfully');
}
And I really want to use the create method, its just looks much cleaner and simpler.