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">
<br>
</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?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire