Skip to content
Advertisement

If you don’t want Eloquent to automatically manage created_at and updated_at columns, which of the following will be correct?

  1. Set the model $timestamps property to false.

  2. Eloquent will always automatically manage created_at and updated_at columns.

  3. Set the model $created_at and updated_at properties to false.

I searched the net and found a lot of solution and what must be the real answer to this question,

I found that we can disable it add a line into the eloquent to make timestamp false

class User extends Eloquent {

    protected $table = 'users';

    public $timestamps = false;

}

But we can also remove the created_at and updated_at and do not use it in the model so 3rd point is also true here?

So what is the proper solution for this question?

Advertisement

Answer

you should set the $timestamps property to false in your model. and not add the timestamp columns ($table->timestamps();) in your table migration.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement