Laravel Select Dropdown From Database Example

Today, We want to share with you laravel dropdown from database.In this post we will show you create dropdown from database value selected in laravel., hear for how to show select box with selected option dynamically in laravel. we will give you demo and example for implement.In this post, we will learn about How To Show Selected Value From Database In Dropdown Using Laravel? with an example.

how to retrieve data from database whenever select in drop down list in laravel?

Controller Code

* Show records
* @return \Illuminate\Http\Response

public function dropDownShow(Request $request)
   $outputs = Item::pluck('name', 'id');
   $selectedID = 2;
   return view('outputs.edit', compact('id', 'outputs'));

Example 1 : Using Form

<div class="form-group">
    {!! Form::Label('item', 'Item:') !!}
    {!! Form::select('item_id', $outputs, $selectedID, ['class' => 'form-control']) !!}

Example 2 : Without Using Form

<select class="form-control" name="item_id">
    <option>Select Item</option>
    @foreach ($outputs as $key => $value)
        <option value="{{ $key }}" {{ ( $key == $selectedID) ? 'selected' : '' }}> 
            {{ $value }} 

I hope you get an idea about create dynamic select box with Form class.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.