Many zeros in the modal

Asked

Viewed 44 times

0

I created a test modal in an attempt to return the id value to the view and as there are more than 5000 records in the query, I don’t know what happens.. but prints a million zeros in the modal, does anyone know what can be?

Code of the whole window:

@extends('adminlte::layouts.app')

@section('htmlheader_title')
    Parceiros Lista
@stop

@section('contentheader_title')

@stop

@section('contentheader_description')

@stop

@section('main-content')

    @php
       use App\Http\Controllers\ClienteEnderecoController;
       $cidades = ClienteEnderecoController::getCidades();
    @endphp



    <div class="container-fluid spark-screen">
        <div class="row">

            <div class="col-md-8 col-md-offset-2">

                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">
                            <i class="fa fa-address-book" aria-hidden="true"></i>
                            INCLUIR ENDEREÇO DO PARCEIRO</h3>
                    </div>

                    <div class="box-body">

                        <input type="text" id="id_request" name="id_request" value="" />
                        <input type="text" id="name_request" name="name_request" value="" />
                        <button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#modalCidade">Abrir Modal</button>

                        <!-- Modal para respostas para o usuario -->
                        <div id="modalCidade" class="modal fade" role="dialog" data-backdrop="static">
                            <div class="modal-dialog modal-lg">
                                <!-- Modal content-->
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                                        <h1>{{ trans('adminlte_lang::message.title') }} - Selecione uma cidade</h1>
                                    </div>
                                    <div class="modal-body">

                                        <div id="TableExt" style="box-shadow: 1px 1px 6px silver; padding: 20px; background-color: white;">

                                            <div class="row">

                                                <div class="col-xs-12">

                                        <table class="table table-bordered table-hover dt-responsive">
                                            <thead>
                                            <tr>
                                                <th hidden>NOME</th>
                                                <th>CIDADE</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            @foreach($cidades as $c)
                                                <tr>
                                                    <td hidden>{{$c->cidade_nome}}</td>
                                                    <td>
                                                        <button type="button" class="btn-link" onclick="devolveid('{{$c->cidade_id}}', '{{$c->cidade_nome}}')">{{$c->cidade_nome}}</button>
                                                    </td>0
                                                </tr>
                                            @endforeach
                                            </tbody>
                                        </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-primary" data-dismiss="modal">Fechar</button>
                                    </div>
                                </div>
                            </div>
                        </div>


                    </div>

                </div>

            </div>

        </div>
    </div>

    <script type="text/javascript">
      function devolveid(id, name) {
        document.getElementById('id_request').value = id;
        document.getElementById('name_request').value = name;
        $('#modalCidade').modal('hide');
      }
    </script>

@endsection

Search method of cities:

public static function getCidades(){
   return $array = DB::select(
        "Select 
            paises.id as pais_id, 
            paises.nome as pais_nome, 
            estados.id as estado_id, 
            estados.nome as estado_nome, 
            cidades.id as cidade_id, 
            cidades.nome as cidade_nome 
        from cidades 
        inner join estados
                  on estados.id = cidades.estado_id 
        inner join paises 
                  on estados.pais_id = paises.id");
}

Imagery:

inserir a descrição da imagem aqui

  • 2

    I’ve never messed with the lockbox but your code has a 0 inside your foreach($cidade as $c) </td>0 must be the reason why.

  • That’s right! Thank you very much!

1 answer

1


@extends('adminlte::layouts.app')

@section('htmlheader_title')
    Parceiros Lista
@stop

@section('contentheader_title')

@stop

@section('contentheader_description')

@stop

@section('main-content')

    @php
       use App\Http\Controllers\ClienteEnderecoController;
       $cidades = ClienteEnderecoController::getCidades();
    @endphp



    <div class="container-fluid spark-screen">
        <div class="row">

            <div class="col-md-8 col-md-offset-2">

                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">
                            <i class="fa fa-address-book" aria-hidden="true"></i>
                            INCLUIR ENDEREÇO DO PARCEIRO</h3>
                    </div>

                    <div class="box-body">

                        <input type="text" id="id_request" name="id_request" value="" />
                        <input type="text" id="name_request" name="name_request" value="" />
                        <button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#modalCidade">Abrir Modal</button>

                        <!-- Modal para respostas para o usuario -->
                        <div id="modalCidade" class="modal fade" role="dialog" data-backdrop="static">
                            <div class="modal-dialog modal-lg">
                                <!-- Modal content-->
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                                        <h1>{{ trans('adminlte_lang::message.title') }} - Selecione uma cidade</h1>
                                    </div>
                                    <div class="modal-body">

                                        <div id="TableExt" style="box-shadow: 1px 1px 6px silver; padding: 20px; background-color: white;">

                                            <div class="row">

                                                <div class="col-xs-12">

                                        <table class="table table-bordered table-hover dt-responsive">
                                            <thead>
                                            <tr>
                                                <th hidden>NOME</th>
                                                <th>CIDADE</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            @foreach($cidades as $c)
                                                <tr>
                                                    <td hidden>{{$c->cidade_nome}}</td>
                                                    <td>
                                                        <button type="button" class="btn-link" onclick="devolveid('{{$c->cidade_id}}', '{{$c->cidade_nome}}')">{{$c->cidade_nome}}</button>
                                                    </td>
                                                </tr>
                                            @endforeach
                                            </tbody>
                                        </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-primary" data-dismiss="modal">Fechar</button>
                                    </div>
                                </div>
                            </div>
                        </div>


                    </div>

                </div>

            </div>

        </div>
    </div>

    <script type="text/javascript">
      function devolveid(id, name) {
        document.getElementById('id_request').value = id;
        document.getElementById('name_request').value = name;
        $('#modalCidade').modal('hide');
      }
    </script>

@endsection

There was a zero left inside the loop of repetition.

  • A no I do not believe.. I searched, searched and did not see! Thank you very much indeed!!!

  • 1

    Beauty! Only gives an acceptance in my answer :)

Browser other questions tagged

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