mercredi 27 avril 2016

How to load option's id from database in Laravel 5.1

I tried to load my options from database, my value set correctly but id loaded incorrect :

Controller :

    $country_list = contry::lists('name','id');
    $country_list = array_merge(array('0' => 'Please Select...'),   $country_list->toArray());

View :

    {!! Form::select('country_id',$country_list,null,['class'=>'form-control']) !!}

Database :

"1"=>"USA"
"2"=>"IRAN"
--> "5"=>"ENGLAND" <--

Load in browser :

"0"=>"Please Select"
"1"=>"USA"
"2"=>"IRAN"
--> "3"=>"ENGLAND" <--

I need option id same to id column in database



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire