How to update the updated_at column when the user logs in?
eloquent, laravel, mysql
Solution
You can use the Eloquent method `touch()` for this:
//instead of
$user->updated_at = DB::raw('NOW()');
$user->save();
// simply this:
$user->touch();
Problem
I'm trying to update the `updated_at` column to the current time, each time a user logs in. But I get the following error: InvalidArgumentException A four digit year could not be found Data missing 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'); } } ```