Disable Laravel's Eloquent timestamps

后端 未结 10 1489
余生分开走
余生分开走 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:33

    In case you want to remove timestamps from existing model, as mentioned before, place this in your Model:

    public $timestamps = false;
    

    Also create a migration with following code in the up() method and run it:

    Schema::table('your_model_table', function (Blueprint $table) {
        $table->dropTimestamps();
    });
    

    You can use $table->timestamps() in your down() method to allow rolling back.

提交回复
热议问题