Limit a table to the print page limit

Asked

Viewed 32 times

-1

Good afternoon, I’m new to programming and I’m testing some things hehehe.

I wonder if it is possible to generate a limited table with empty spaces (according to the image) that the limit would be the size of the printing page.

inserir a descrição da imagem aqui

Currently I loop inside the data and displays in the table, but it is already defined 40 more lines with empty fields, only for occupation.

@foreach($testes->sortBy('created') as $teste)
          <tr class="row3">
            <td class="column0 style6 null" style="padding:3px">{{data_brasil($teste->created)}}</td>
            <td class="column1 style1 null" style="padding:3px">{{$teste->nome ?? "Não Definido"}}</td>
            <td class="column2 style1 null" style="padding:3px"></td>
            <td class="column3 style1 null" style="padding:3px">{{$teste->numero}}</td>
            <td class="column4 style1 null" style="padding:3px"></td>
            <td class="column5 style1 null" style="padding:3px"></td>
            <td class="column6 style1 null" style="padding:3px"></td>
          </tr>
      @endforeach
      <tr class="row4">
        <td class="column0 style6 null"></td>
        <td class="column1 style1 null"></td>
        <td class="column2 style1 null"></td>
        <td class="column3 style1 null"></td>
        <td class="column4 style1 null"></td>
        <td class="column5 style1 null"></td>
        <td class="column6 style1 null"></td>
      </tr>
      <tr class="row5">
        <td class="column0 style6 null"></td>
        <td class="column1 style1 null"></td>
        <td class="column2 style1 null"></td>
        <td class="column3 style1 null"></td>
        <td class="column4 style1 null"></td>
        <td class="column5 style1 null"></td>
        <td class="column6 style1 null"></td>
      </tr>
      <tr class="row45">
        <td class="column0 style6 null"></td>
        <td class="column1 style1 null"></td>
        <td class="column2 style1 null"></td>
        <td class="column3 style1 null"></td>
        <td class="column4 style1 null"></td>
        <td class="column5 style1 null"></td>
        <td class="column6 style1 null"></td>
      </tr>

Summarizing the question: Is there a way to limit the table by the print sheet? and if it has a specific name for this action?

Ps: I did not find a question that helped me in this case.

Thanks in advance.

1 answer

0


First question, are you using the eloquent for the consultation? If yes you can limit the number of items in various ways, I advise using limit() or paginate(). The limit limits the amount of records in the sql query. Ex:

$users = DB::table('users')
            ->offset(10)
            ->limit(5)
            ->get();

The paginate in which I strongly recommend is used in Quotations, you arrow the amount of items you want to receive per page and pass the page number in Querystring in the request Ex:

Na url da requisição Get passe a variável page contendo a página desejada (querystring). 
Ex: http://example.com/admin/users?page=1

And in the query pass the amount of items per page:

'users' => DB::table('users')->paginate(15)

This way you can pass the current page of your document and search only for the quantity informed per page

  • I did not know this functionality, and it worked very well, obg!

Browser other questions tagged

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