database wont update

Posted 9 months ago by megaman7

I am attempting to update a database row using the following code

" $timeOut = Timeout::where('user_id','=',$request->user()->id)->first(); $timeOut->last_activity = Carbon::now(); $timeOut->save(); "

and i keep getting the following error.

[2018-08-01 16:38:29] local.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: update timeouts set last_activity = 2018-08-01 16:38:29, updated_at = 2018-08-01 16:38:29 where id is null) {"userId":1,"email":"[email protected]","exception":"[object] (Illuminate\Database\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: update timeouts set last_activity = 2018-08-01 16:38:29, updated_at = 2018-08-01 16:38:29 where id is null) at /mnt/c/code/neuroordering/neuroordering_secure/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' at /mnt/c/code/neuroordering/neuroordering_secure/vendor/laravel/framework/src/Illuminate/Database/Connection.php:479)

I have checked that $timeOut::where() is returning a model. I have checked that my user_id is correct i have checked that Carbon::now() is returning a valid datetime string

yet as soon as i call the save() function that error appears.

Why?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.