Dropdown in laravel

Published 9 months ago by anp24

How do I fill the drop down through controller and the drop down is placed in blade.php. Drop down must be multi select. Also only server side php mvc laravel code is required.


Please reply as it is urgent

9 months ago (151,880 XP)

@anp24 Controller

class TestController extends Controller
    public function index()
        return view('form')
            ->with('options', [
//        return view('form')->with('options', YouModel::all());


<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.2.1.min.js">
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
  $(document).ready(function() {

<select name="test" multiple="multiple">
    @foreach($options as $option)
        <option value="{{ $option }}">{{ $option }}</option>

Please sign in or create an account to participate in this conversation.