Laravel Eloquent与没有';不需要时间戳()


Laravel Eloquent With Tables that don't need timestamps()

我一直在几个地方寻找这个答案,但还没有找到解决方案。

我的一个表——一个非常简单的两列表——不需要created_at或updated_at字段。然而,雄辩给了我一个错误,因为它试图自动添加这两个字段。

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into `stimuli_tracker` (`session_id`, `stimulus`, `stimulus_type`, `updated_at`, `created_at`) values (3, cat, sample, 2015-11-14 16:49:16, 2015-11-14 16:49:16))

Laravel或Eloquent似乎在增加这两个领域,但它们显然不存在。我如何让Laravel/Eloquent绕过这张表上的这个功能。

谢谢!

您需要将模型上的时间戳属性设置为false:

public $timestamps = false;

请参阅以下位置的"时间戳"部分:http://laravel.com/docs/5.1/eloquent#eloquent-模型约定