2
In an application I am doing the following to load my Bootstrap Modals
index.blade.php
Obs: data-target(#Edit{$ecategory->id}}) used to call modals
@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 managed 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 generate dynamically, but I was unsuccessful. someone has a solution?
This way what I’m doing is working, it’s not getting any wrong information, what I want is to take this loop, and load the modal dynamically, but take advantage of Edit.blade.php and the route
– Jean Prado
In this case you can do an if in Blade for example: @if(Rout::getCurrentRouteName() == "Rotax") HERE IS WHAT YOU WANT TO SHOW @endif
– Fabio William Conceição
not understood very good, but is giving error Undefined offset: 0
– Jean Prado
Another example: @if(Route::currentRouteName() == "lancings.index" ) @include('layout.header-with-blue-menu') @end Another example, I use this to modify the aesthetic structure of menus
– Fabio William Conceição
That doesn’t solve my case.
– Jean Prado