How to display the index of the tag and not its name?

Greetings to all. Deal with larval and relationships.
Is html here to display the list of categories. The usual CRUD application.
<select class="form-control select2" multiple data-placeholder="Select a State" style="width: 100%;" name="categories[]" tabindex="-1" aria-hidden="true">
 @foreach($categorys as $category)
 <option value="{{ $category->id }}">{{ $category->name }}</option>
@endforeach
 </select>

Next, the controller to write to the DB
$post = post::find($id);
$post->fill($req->all());
$post->categories()->sync($req->categories);
 $post->save();

Question:
Why, if I check the response $req->all() that displays "categories":["Ghbdtn"]and not "categories":["1"]? For the record in DB.
June 3rd 19 at 19:34
1 answer
June 3rd 19 at 19:36
Check that you have a value in the select. The array should get the values from this attribute.

Find more questions by tags Laravel