<select class="form-control select2" multiple="" name="items[]" >
@foreach ($itemss as $item)
<option value="{{ $item->id }}">{{ $item->name }}</option>
@endforeach
</select>
--Model--
TableA
TableA_TableB
TableB
--Controller-
foreach($request->items as $itemId) {
$table_AB = new TableA_TableB();
$table_AB->$table_a_id = $table_a->id;
$table_AB->table_b_id = $itemId;
$table_AB->save();
}
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme