php - How to use CASE WHEN in Eloquent ORM? - Stack Overflow

PHOTO EMBED

Fri Apr 16 2021 14:52:54 GMT+0000 (UTC)

Saved by @mvieira

->select('users.id AS user_id', 'users.name',
DB::raw('(CASE WHEN users.status = 0 
THEN "active" WHEN users.status = 1 
THEN "not active" 
ELSE "pending" END) AS 
status_user'))
->orderBy('shares.created_at', 'desc') 
content_copyCOPY

https://stackoverflow.com/questions/46949095/how-to-use-case-when-in-eloquent-orm