Skip to content
Advertisement

Laravel using a case statement

I’m trying to retrieve all messages of a conversation and display it’s status (read or unread). With a CASE I try to read the message.read property (boolean) and process it to a string.

Without the CASE, the query works fine but with the case I recieve a Syntax error or access violation: 1064 near 'read.

Advertisement

Answer

Solved it by placing both the outcomes read and unread in double quotes.

Now I can use the status directly as a css class!

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