I have the following in my controller:
$companies = Company::pluck('title', 'id')->toArray();
Which gets send to a view with a form using Laravel Collective. Inside this view i have the following piece of code to show the array in the select box:
<div class="form-check">
{{ Form::label('company_id', 'Bedrijf', ['class'=>'label']) }}<br>
{{ Form::select('company_id', $companies, null, ['class' => 'form-control chosen-select', 'placeholder' => 'None', 'id' => 'company_id']) }}
</div>
This generates the given title in a dropbox, as intended. However, i want my ID's to be the same as my company_id from my controller. Now it's just a list from 0 to the array's length. To clarify: the desired result should look like:
<li class="active-result" data-option-array-index="Company id">Company title</li>
<li class="active-result" data-option-array-index="Company id">Company title</li>
<li class="active-result" data-option-array-index="Company id">Company title</li>
However, my indexes are just incremental and do not correspond with the company id's at all:
<li class="active-result" data-option-array-index="0">Company title</li>
<li class="active-result" data-option-array-index="1">Company title</li>
<li class="active-result" data-option-array-index="2">Company title</li>
How can I achieve this?