In an application I'm doing the following to load my Bootstrap Modals
index.blade.php
obs: data-target (#edit {{$ ecategory-> id}}) used to call modal
@foreach($ecategories as $ecategory) //listando os registros
<tr class="danger">
<td>{{ $ecategory->name }}</td>
<td> <a href="{{route('categories.edit', ['id'=>$ecategory->id])}}" data-toggle="modal" data-target="#edit{{$ecategory->id}}" class="btn btn-default btn-sm" >Editar</a>
<a href="{{route('categories.destroy', ['id'=>$ecategory->id])}}" class="btn btn-danger btn-sm" >Excluir</a> </td>
</tr>
@endforeach
@foreach($ecategories as $ecategory) // listando os modals de cada registro
<div class="modal fade" id="edit{{$ecategory->id}}" tabindex="-1" role="dialog" aria-labelledby="categoryedit_title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
@endforeach
edit.blade.php
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 id='categoryedit_title' class="modal-title">Editando Categoria</h4>
</div>
<div class="modal-body">
@include('errors._check')
{!! Form::model($category, ['route'=>['categories.update', $category->id]]) !!}
@include('categories._form')
<div class="form-group" >
{!! Form::submit('Atualizar Categoria', ['class'=>'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
So I was able to open the modal of each record, but then my html gets full of modals
<div class="modal fade" id="edit2" tabindex="-1" role="dialog" aria-labelledby="categoryedit_title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
<div class="modal fade" id="edit5" tabindex="-1" role="dialog" aria-labelledby="categoryedit_title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
<div class="modal fade" id="edit6" tabindex="-1" role="dialog" aria-labelledby="categoryedit_title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
<div class="modal fade" id="edit7" tabindex="-1" role="dialog" aria-labelledby="categoryedit_title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
<div class="modal fade" id="edit8" tabindex="-1" role="dialog" aria-labelledby="categoryedit_title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
I'm trying to dynamically generate, but I was not successful. does anyone have a solution?