I am trying to convert my mysql query logic to Laravel query builder. I I have no Idea how to convert it as laravel query.
my query logic is
SELECT id,name,
case
when visibility_status = '1'
then 'Visible'
when visibility_status = '0'
then 'Invisible'
end as visibility_status FROM `flowers`
generally I write a select query using query builder but cant implement above logic
$result = DB::table('flowers')
->select('flowers.id as id', 'flowers.name as name',
'flowers.visibility_status as visibility_status');
0|Invisible, 1|Visible. Then in either plain SQL or in (non-raw-query) Laravel Query Builder you'd just join from flowers to the decode table and read the value from there. Alternatively, just read the 0 and the 1 and decode them directly in the Laravel View where you output them, assuming that's what you're doing with them.