Disable Laravel's Eloquent timestamps

后端 未结 10 1479
余生分开走
余生分开走 2020-12-04 08:54

I\'m in the process of converting one of our web applications from CodeIgniter to Laravel. However at this moment we don\'t want to add the updated_at / c

10条回答
  •  渐次进展
    2020-12-04 09:32

    You either have to declare public $timestamps = false; in every model, or create a BaseModel, define it there, and have all your models extend it instead of eloquent. Just bare in mind pivot tables MUST have timestamps if you're using Eloquent.

    Update: Note that timestamps are no longer REQUIRED in pivot tables after Laravel v3.

    Update: You can also disable timestamps by removing $table->timestamps() from your migration.

提交回复
热议问题