updated_at 컬럼 사용하지 않기

Submitted by river - 등록 8 years ago - 수정 8 years ago

Laravel Eloquent는 timestamp 컬럼인 created_at, updated_at 에 대해서 자동으로 날짜를 설정하고, 갱신하는 작업을 수행하다.

이 중 created_at 컬럼은 사용하고, updated_at 컬럼은 사용하지 않을 경우에는 다음의 메서드를 모델에 추가하면 된다.

public function setUpdatedAt($value)
{
    // Do nothing.
}

참고로, 다음과 같이 하면 두 컬럼을 모두 사용하지 않는다고 설정하는 게 된다.

public $timestamps = false;

관련글

comments powered by Disqus