7
votes

This is my table structure

    public function up()
    {
        Schema::create('tags', function($table){
            $table->increments('tagId');
            $table->string('tagName');
            $table->timestamp('tagCreated');
        });
    }

When I store a record, it says me column not found. Even I am not using "$table->timestamps();"

Please help how to fix it? Is it necessary to store "timestamps()" for every table?

Illuminate \ Database \ QueryException

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into tags (tagName, tagCreated, updated_at, created_at) values (test, 2014-02-08 16:19:04, 2014-02-08 11:19:09, 2014-02-08 11:19:09))

1

1 Answers

20
votes

You need to tell the model that you're not using timestamps by adding

 public $timestamps = false;

To your model class. You can read more about them here: http://laravel.com/docs/eloquent#timestamps

Note that the scheme migrations is just for the database - not the model. There is no way for Laravel to know that you didn't invoke "timestamps" in the migration. You need to specify the relationship between the model and the schema in your model classes - while the migrations simply worry about the database directly.