Showing YES or NO instead of 1 and 0 in a php table

Viewed 180

i have an SQL table where I've got various checkboxes and when displaying them in a view, the values are shown as 0 and 1. I know that 0 is false and 1 is true, but the user may not... is there any way to make this show as yes or no?

Here is my table code:

<tbody>
    @foreach ($survey as $data)
        <tr>
            <td>{{$data->satisfied}}</td>
            <td>{{$data->would_recommend}}</td>
        </tr>
    @endforeach
</tbody>
1 Answers

You can solve this in the SQL query itself.

Like this:

SELECT would_recommend, 
    CASE
        WHEN `satisfied` = '1' THEN 'YES' 
        WHEN `satisfied` = '0' THEN 'NO'
    END
FROM orders;
Related