jeudi 5 juillet 2018

How to use "enum" values in select option in Laravel?

I have problem with build select in Laravel blade and use only two types values from database I have column
$table->enum('contact_way', ['email', 'phone']);
in my migraton and i have to use it in my blade form to update, I use simple @if statement but it is not good

                                <select class="form-control" name="contact_way">
                                @if ($customer_event->contact_way === "email")
                                <option value="email" selected>Kontakt e-mail</option>
                                <option value="phone" >Kontakt telefoniczny</option>
                                @else
                                <option value="email" >Kontakt e-mail</option>
                                <option value="phone" selected>Kontakt telefoniczny</option>
                                @endif
                            </select>

I want to use foreach staement where I use this to things and check witch one is correct and this show like selected but I don't know how to do it

Aucun commentaire:

Enregistrer un commentaire