반응형
사용자가 로그인 할 때마다 updated_at
열을 현재 시간으로 업데이트하려고합니다.
하지만 다음과 같은 오류가 발생합니다.
InvalidArgumentException 4 자리 연도를 찾을 수 없습니다. 데이터가 없습니다.
PHP
$input = Input::all();
$remember = (Input::has('remember')) ? true : false;
$auth = Auth::attempt([
'username' => $input['username'],
'password' => $input['password'],
'active' => 1
],$remember
);
if ($auth)
{
$user = Auth::user();
$user->updated_at = DB::raw('NOW()');
$user->save();
if ($user->userType==1)
{
return Redirect::intended('admin');
}
elseif ($user->userType==2)
{
return Redirect::intended('corporate');
}
elseif ($user->userType==3)
{
return Redirect::intended('trainer');
}
elseif ($user->userType==4)
{
return Redirect::intended('user');
}
}
해결 방법
이를 위해 Eloquent 메서드 touch ()
를 사용할 수 있습니다.
//instead of
$user->updated_at = DB::raw('NOW()');
$user->save();
// simply this:
$user->touch();
참조 페이지 https://stackoverflow.com/questions/23132758
반응형
'MySql' 카테고리의 다른 글
MySQL SQL 주입을 방지하기 위해 mysql_real_escape_string을 어디에 사용합니까? (0) | 2020.12.06 |
---|---|
MySQL 라운드가 예상보다 더 많이 떠 다니는 이유는 무엇입니까? (0) | 2020.12.06 |
MySQL에서 모든 이벤트를 삭제하는 방법 (0) | 2020.12.06 |
MySQL pymysql (DictCursor)로 데이터 가져 오기 (0) | 2020.12.06 |
MySQL 저장 프로 시저로 인해 다음 쿼리에서 "명령이 동기화되지 않음"발생 (0) | 2020.12.06 |
댓글