禁用 Laravel 的 Eloquent 时间戳 - Disable Laravel's Eloquent timestamps

问题:

I'm in the process of converting one of our web applications from CodeIgniter to Laravel.我正在将我们的一个 Web 应用程序从 CodeIgniter 转换为 Laravel。 However at this moment we don't want to add the updated_at / created_at fields to all of our tables as we have a logging class that does all this in more depth for us already.然而,此时我们不想将updated_at / created_at字段添加到我们所有的表中,因为我们有一个日志类已经为我们更深入地完成了所有这些工作。

I'm aware I can set $timestamps = false;我知道我可以设置$timestamps = false; in:在:

Vendor\laravel\framework\src\illuminate\Datebase\Eloquent\Model.php

However I'd rather not change a core file for Laravel, or have everyone of my models have that at the top.但是,我宁愿不更改 Laravel 的核心文件,也不想让我的每个模型都将其放在顶部。 Is there any way to disable this elsewhere for all models?有没有办法在其他地方为所有型号禁用此功能?


解决方案:

参考一: https://en.stackoom.com/question/1Lefd
参考二: https://stackoom.com/question/1Lefd
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章