0
所以我有一個數據透視表thread_user
,我有兩個模型; User.php和Thread.php。Laravel - belongsToMany關係時間戳
我有這個在我的user.php的文件:
public function threads()
{
return $this->belongsToMany('App\Thread')->withTimestamps();
}
我只希望created_at時間戳雖然。我不想要updated_at,並且每次嘗試將某些內容附加到數據透視表時,我都會收到此錯誤:Column not found: 1054 Unknown column 'updated_at' in 'field list'...
。這真的很煩人。由於某些原因,我不能有updated_at
時間戳,但我仍然需要created_at
時間戳。
請讓我知道如何解決這個問題。我已經試過,沒有運氣以下:
return $this->belongsToMany('App\Thread')->withTimestamps(['created_at']);
請幫助。謝謝!