Simple laravel 5 pagination links - laravel

In my controller I'm displaying records in a table in my View.
Controller:
$promotion = Promotions::paginate(5);
View:
<tr>
<th>Order</th>
<th>Infomation</th>
<th>Date</th>
<th>Cost</th>
<th>From</th>
</tr>
</thead>
<tbody align="center">
<?php $i = 0;?>
#foreach ( $promotion as $promo)
<?php $i++;?>
<tr>
<td data-title="Order">{{$i}}</td>
<td data-title="Infomation">{{$promo['name']}}</td>
<td data-title="Date">29/10/57</td>
<td data-title="Cost">1.99$</td>
<td data-title="From">K-Bank</td>
</tr>
#endforeach
</tbody>
It works properly when I locate manually to exampleurl/mypage?page=2
All seems well. However, I wanted to create two text buttons to go back and fourth between pages.
How can I set these to navigate the pagination back and fourth:
Previous
Next
EDIT: I don't understand why I'm getting downvoted for this question. No where can I find a tutorial on how to split the back and fourth buttons. How professional can your website be if you're restricted to placing the page links to one spot on the page? seriously...

In Laravel 5 there is a single configuration option for Eloquent models to generate pagination. So, you can use the method:
<?php echo $promotion->render(); ?>
If you want an option only with Previous and Next buttons, you need to use
$promotion = Promotions::simplePaginate(5);
Instead of
$promotion = Promotions::paginate(5);

Related

MPDF getting value from previous page with autopagebreak

I have data with 200 records and each page must have title of that data's category with total sum of data from previous page but when auto page break trigger to new page I just want $total value from the first page using in other page
for example
$total =0;
<table>
<thead>
<tr>
<th>Category 1</th>
<th>total = {$total}</th>
</tr>
</thead>
<tbody>
foreach($data in $list):
<tr>
<td>$data->name;</td>
<td>$data->total;</td>
</tr>
$total+=$data->total
endforeach;
</tbody>
</table>
in this table when auto page break trigger and title of the total value in new page become 0
how to use global value for every pages?
thank you

How do I bind a value to a TCustomAttribute in Aurelia?

I'm trying to achieve the following result: I have a set of values that are coming from an array which I iterate over in order to populate an HTML table. As well I have an icon that user can hoover-over and can see data in there coming from the array and a translation key coming from translation files.
I want to bind a second argument to the TCustomAttribute in order to display to the user another data that was edited by them.
How do I achieve this in Aurelia?
<template>
<table>
<thead>
<th><span>Id</span></th>
<th><span>Name</span></th>
<th><span>Description</span></th>
<th><span>Date</span></th>
</thead>
<tbody>
<tr repeat.for="item of data">
<td><span>${item.Id}</span></td>
<td><span>${item.Name}
<a data-toggle="popover" t="[data-content]pending_name ${data.Name}" data-trigger="hover">
<i class="fa fa-info-circle"></i>
</a>
</span></td>
<td><span>${item.Description}</span></td>
<td><span>${item.Date}</span></td>
</tr>
</tbody>
</table>
</template>
Take a look at the t-params attribute which allows you to pass in additional parameters. More about that in the official guide http://aurelia.io/docs/plugins/i18n#using-the-plugin

PowerApps: Use HTML to modify form display in model-driven apps?

I need to modify the format of a form in a model-driven app to make it more readable/intuitive. Currently, the form looks like this:
I tried to use a web resource to create a simple HTML table with <script> and Xrm.Page.getAttribute() to pull in the relevant fields under the planned and actual columns, but that isn't working. I set the dependencies and assigned it to the proper form element, but no luck. The code that I used is this:
<div>
<table>
<tr>
<td><u>Tasks</u></td>
<td><u>Planned</u></td>
<td><u>Actual</u></td>
</tr>
<tr>
<td>Task 1</td>
<td><script>Xrm.Page.getAttribute("[plannedField_1]")</script></td>
<td><script>Xrm.Page.getAttribute("[actualField_1]")</script></td>
</tr>
<tr>
<td>Task 2</td>
<td><script>Xrm.Page.getAttribute("[plannedField_2]")</script></td>
<td><script>Xrm.Page.getAttribute("[actualField_2]")</script></td>
</tr>
<tr>
<td>Task 3</td>
<td><script>Xrm.Page.getAttribute("[plannedField_3]")</script></td>
<td><script>Xrm.Page.getAttribute("[actualField_3]")</script></td>
</tr>
</table>
</div>
Is this a valid way to modify form output, or is there another/better way to do this that doesn't involve creating an elaborate solution with dynamically scripted HTML?
Uncheck the Display label on the form for one of the controls.

Circumvent Boostrap-Table from rendering 100+ rows slowly

I'm rendering a list of state objects (with Spring and Thymeleaf) on my view page:
<table id="state-table" data-toggle="table" data-pagination="true" data-pagination-v-align="top" data-search="true">
<thead>
<tr>
<th data-sortable="true">ID</th>
<th data-sortable="true">Descrizione</th>
<th>Azioni</th>
</tr>
</thead>
<tbody>
<tr th:each="s : ${state}">
<td><span th:text="${s.id}"></span></td>
<td><span th:text="${s.descrizione}"></span></td>
</tr>
</tbody>
</table>
The table contains about 150 elements, but when the page is rendering I see for less than a second an ugly page (is the plugin trying to paginate the result) and I would like to avoid it.
I have already tried adding a timeout as workaround:
$(function() {
$("#state-table").bootstrapTable("showLoading");
setTimeout(function() {
$("#state-table").bootstrapTable("hideLoading");
}, 1000);
});
but with this code, when the page renders, I see a strange html page at beginning, then I see the loading message, and finally the table with all elements loaded.
I think I have to intervene before (or while) the table is created but I don't know how. What would I need to do so that the table is rendered correctly without the user noticing the ugly "un-bootstraped" table?
Try To use Pagination instead of showing all your entries.
Hope it help you : https://www.baeldung.com/spring-thymeleaf-pagination

Aurelia - Require feature to handle reference tracking of a particular filter result when applying multiple filters?

Have a table with the filtering and sorting like so:
<tbody>
<tr class="row"
repeat.for="repo of repos |
filter:searchField.value:filterGitHubTable |
sort: {propertyName: column.value, direction: direction.value} |
pageData:{currentPage: pageNumber, pageSize:pageSize}">
<td class="col-xs-3">${repo.name}</td>
<td class="col-xs-3">${repo.stargazers_count}</td>
<td class="col-xs-3">${repo.forks_count}</td>
<td class="col-xs-3">${repo.open_issues}</td>
</tr>
</tbody>
In my pager code below its setup as
<pagination model.bind="repos"
page-size.bind="pageSize"
pageclick.delegate="handlePageClick($event)"
pagination-class="pg-bluegrey"></pagination>
How to make the pagination element model bind to the reference of a filter result 'after the sorting' but 'before it does the next filter for pagination data'?
The reason is once have pagination data, I don't have the whole filter result to bind with the pagination element. How would I keeping track of page numbering when applying the filter on the table result?
Here's a little trick you might be able to use here. You can use a hidden HTML element to sort of "hold on" to an intermediate version of your data. Aurelia allows you to attach arbitrary attributes to any element, and by using the ref attribute, we can attach the element itself to our viewmodel. We can then access any data we've attached to this element anywhere we want in our view or viewmodel. Check this out:
<input type="hidden" ref="filteredAndSorted"
data.bind="repos |
filter:searchField.value:filterGitHubTable |
sort: {propertyName: column.value, direction: direction.value}" />
<table>
<tbody>
<tr class="row" repeat.for="filteredAndSorted.data |
pageData:{currentPage: pageNumber, pageSize:pageSize}">
<td class="col-xs-3">${repo.name}</td>
<td class="col-xs-3">${repo.stargazers_count}</td>
<td class="col-xs-3">${repo.forks_count}</td>
<td class="col-xs-3">${repo.open_issues}</td>
</tr>
</tbody>
</table>
<pagination model.bind="filteredAndSorted.data"
page-size.bind="pageSize"
pageclick.delegate="handlePageClick($event)"
pagination-class="pg-bluegrey">
</pagination>
I'm betting this is what will help you. Sorry it took so long to answer, I've been quite busy the last few days doing Aurelia training.

Resources