laravelpluck

Laravel Pluck Selected option


i wants to show selected category option in Sub-category edit form.
Am using pluck function for fetch category from database.

{{ Form::model($subcategories,['route'=> ['subcategories.edit',$subcategories->id],'method'=>'post']) }}

 <div class="form-group">
   {{ Form::label("","Sub Category ") }}
   {{ Form::select('category_id',$categories,null,['class'=>'form-control']) }}
 </div>


 <div class="form-group">
    {{ Form::label("","Sub Category ") }}
    {{ Form::text('sub_category_id',old('sub_category_id'),['class'=>'form-control']) }}
 </div>
 <div class="form-group">

    {{ Form::submit('UPDATE',['class'=>'form-control']) }}
 </div>

{{ Form::close() }}

How to do this ?


Solution

  • pass array of selected values in place of 3rd arguments of select() Ex.

    {{ Form::select('category_id',$categories,$selected_categories,['class'=>'form-control']) }}