Skip to content
Advertisement

Laravel where in an update statement in the controller

I have this function in my controller which works:

JavaScript

Now I would like to change the update statement to this:

JavaScript

But this doesn’t work.. its in my where statement but I don’t know what I am doing wrong?

But this still updates all of the email_send columns in my database. even though it now should only update the ones in the past.

I dont get an error message

Advertisement

Answer

The where statement doesn’t work like this

->where('userID', Auth::id(), 'EindDatum' < Carbon::now())

The problem is that the where clause doesn’t know how to mach your expression.

You need to udpate your code like this

JavaScript

The result will be Where Userid = Auth::id() AND EindDatum < Carbon::now()

Where Auth::id() and Carbon::now are replaced with the values returned from the facades.

Edit: Made the code easier to read.

More about the where clauses

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement