Problem with Laravel + Adminlte application

Asked

Viewed 464 times

1

My problem is the following, the application I am developing has a customer listing, which uses the following code for display:

<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-body">
                    <table id="data-table-clientes" class="table table-bordered table-hover">
                        <thead>
                        <tr>
                            <th class="col-xs-1">#</th>
                            <th class="col-xs-2">CNPJ</th>
                            <th class="col-xs-2">Razão Social</th>
                            <th class="col-xs-2">Nome Fantasia</th>
                            <th class="col-xs-2">Email</th>
                            <th class="col-xs-2"></th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php $i = 0 ?>
                        @foreach( $clientes as $cliente )
                            <tr>
                                <td>{{(($clientes->currentPage() - 1 ) * $clientes->perPage() ) + (++$i)}}</td>
                                <td>{{$cliente->cnpj}}</td>
                                <td>{{$cliente->razao_social}}</td>
                                <td>{{$cliente->nome_fantasia}}</td>
                                <td>{{($cliente->email)}}</td>
                                <td>
                                    <a class="btn-sm btn-warning margin" href="{{route('clientes.edit', ['id' => $cliente->id])}}" title="Editar">
                                        <i class="fa fa-edit"></i>
                                    </a>
                                    <a class="btn-sm btn-danger" href="{{route('clientes.delete', ['id' => $cliente->id])}}" title="Excluir">
                                        <i class="fa fa-edit"></i>
                                    </a>
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                    {!! $clientes->render() !!}
                </div>
            </div>
        </div>
    </div>
</section>

But sometimes the page suffers a reload (paging is an example), the content is deformed as follows and only back to normal giving reload again.

inserir a descrição da imagem aqui inserir a descrição da imagem aqui

I don’t think it’s the AdminLTE, because I’ve rewritten everything without Laravel for testing purposes, with the same content and the problem did not persist.

Could someone help me solve this problem?

Grateful for the attention.

1 answer

0

Your problem is here:

<td>
  <a class="btn-sm btn-warning margin" href="{{route('clientes.edit', ['id' => $cliente->id])}}" title="Editar">
     <i class="fa fa-edit"></i>
   </a>
  <a class="btn-sm btn-danger" href="{{route('clientes.delete', ['id' => 
  $cliente->id])}}" title="Excluir">
   <i class="fa fa-edit"></i>
  </a>
</td>

There is a simpler way to pass the client ID: {{ route('clientes.edit', $client->id) }}

<td>
  <a class="btn-sm btn-warning margin" href="{{ route('clientes.edit', $client->id) }}" title="Editar">
     <i class="fa fa-edit"></i>
   </a>
  <a class="btn-sm btn-danger" href="{{ route('clientes.edit', $client->id) }}" title="Excluir">
   <i class="fa fa-edit"></i>
  </a>
</td>
  • It still presents the same problem, but thanks for the simplification tip. I think it’s something in the way Blade works, will going to the latest version solves?

  • Oo! Weird. I use it this way, is that not your first Row of page number? I didn’t understand the need for this, to be honest. Why not display the client ID with $client->id?

  • You mean the first column? I need that listing follow an order of records, paginando can locate me in number of records, $client->id would have a gap if any record were deleted.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.