A
A
ashfedor2020-06-05 16:06:01
MySQL
ashfedor, 2020-06-05 16:06:01

Why does the ENUM field in the table produce null even though there is 1?

Hi all! I am writing a small website in Laravel.
Faced such a problem.
The Locale table
has two fields of type ENUM
status for activating the language and favorite for assigning by default
5eda41c970710771450792.jpeg
in the admin panel in the table, it normally displays whether the language is active or not

@if ($item->status == 1)
                                <span class="">{{__('admin.active')}}</span>
                            @else <span class="">{{__('admin.destroy')}}</span>
                            @endif


But if I try to show which language is the default, then such a construction does not work
@if($item->favorite == 1)
                                <i class="far fa-star"></i>
                            @endif

and if I check what produces {{dd($item->favorite)}}
then I get null although the value in the table is 1
Maybe someone knows what could be the reason. Why does one line work and the other doesn't.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
ashfedor, 2020-06-05
@ashfedor

The question is removed, I just did not pass the favorite field in the method
. Added it and everything worked. In short, stupid)))

D
Dmitry Shitskov, 2020-06-05
@Zarom

Because enum with values ​​'Y' and 'N' have values ​​'1' and '0' in your table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question