Error in Laravel after inserting the save () method


Good afternoon I'm trying at all costs to make an insert in the bank, using Laravel and Controller, however, it does not work at all, I've tried everything that is shape, doing migrate, changing screen name, anyway, in any way and nothing. In my rote, I have this code:

Route::when('*', 'csrf', array('post'));
Route::get('/', 'HomeController@getIndex');
Route::post('save', 'HomeController@postAddUser');
Route::post('login', 'HomeController@postLogin');
Route::group(array('before' => 'auth'), function(){
   Route::controller('profile', 'ProfilesController');

In my Controller, I have the following action:

public function postInserir(){
    $posts = new Post();
    $posts->nome = Auth::user()->nome;
    $posts->post = Input::get('text_post');

    return Redirect::to('/');


 class Post extends Eloquent{


In my database, I have a table named posts with an auto increment id not null, a field named varchar name 255 not null and a field called post longtext

And this is my View:

<?php echo Form::open(array('action' => 'ProfilesController@postInserir', 'role' => 'form', 'id' => 'post-form')); ?>
        <div class="panel-body">
            <textarea id="text_post" name="text_post" class="form-control" rows="2"></textarea>
        <div class="panel-footer" style="background-color: black;">

            <button type="submit" id="publicar" class="btn btn-primary btn-xs pull-right">Publicar</button>
            <?php echo Form::close(); ?>

If I submit the form, it goes up to the action, it displays what was last and everything else, the problem and when I do I call the $ posts-> save () method, which gives me the message "Whoops , looks .. "

Does anyone know where the problem might be?

asked by anonymous 18.08.2014 / 23:10

1 answer


This is happening because in your table you have not created the columns created_at and updated_ad, to add them to your table, in your schema add the line


This way it will create these columns.

But if you really will not use it because it is a pivot table etc, you can tell the model that when you make some changes and insert, it will not populate these columns so go in the model and add this line

public $timestamps = false;

That's it, that's it!

20.08.2014 / 13:23