lundi 30 octobre 2017

Laravel model binding for select dropdown

I want the select dropdown value to be selected in my edit form.In my controller,

public function edit($id)
{

        $vedit = DB::table('vehicles')->where('id', $id)->first();
        $cartype= DB::table('car_category')->pluck('cartype'); 
        return view('vehicles.edit', compact('vedit','cartype'));
            }

In view,


 <select name="vehicle_type" class="form-control">
@foreach($cartype as $cartypes) 
 <option value=""></option>
@endforeach
</select>

How can I achieve this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire