I have a Laravel 5.2 application. I'm using the default Laravel pagination. All works functionally but there is quite some empty space between the last row of the table and the pagination link. See picture for an example:
How can I make the empty space a bit less?
Here is the code I'm using:
<table class="table table-striped table-bordered table-list">
<thead>
<tr>
<th class="hidden-xs">Auction id</th>
<th>Name</th>
<th>Description</th>
<th><em class="fa fa-cog"></em>Actions</th>
</tr>
</thead>
<tbody>
#foreach( $events as $event )
<tr>
<td align="center" class="hidden-xs">{{ $auction->id }}</td>
<td>{{ $event>name }}</td>
<td>{{ $event->description }}</td>
<td align="center">
<div>
<em class="fa fa-list-alt"></em>
</div>
</tr>
#endforeach
</tbody>
</table>
<div class="text-right">
{{ $events->render() }}
</div>
<div class="text-right">
<!-- Your pagination code here -->
</div>
Related
i found out a way by someone asking a question, of a way of producing subtotals, i now just wanted to sum values between two tables , in the code from the person i tested and it works perfectly, i just wanted to aggregate more one table to any of the querys , it's summing on the blade.
//resumed controller
public function index() {
$emphayas = DB::select('select * from emphayas');
$treasuries = DB::select('select * from treasuries');
return view('database',['emphayas'=>$emphayas,
'treasuries'=>$treasuries,
]);}
-----------------------------------------------------------------
//resumed blade
<table class=" ">
<tr>
<th class="py-3 bg-cyan-400">Total</th>
<td class="py-3 bg-cyan-400">available_for_use_month</td>
</tr>
#foreach ($emphayas as $emphaya)
<tr>
<td></td>
<td>{{ $emphaya->available_for_use_month}}</td>
</tr>
#endforeach
<tr>
<td>Total</td>
<td>{{ \App\Models\Emphaya::sum('available_for_use_month') }}
</tr>
</table>
<table class=" ">
<tr>
<th class="py-3 bg-cyan-400">Total</th>
<td class="py-3 bg-cyan-400">available_for_use_month</td>
</tr>
#foreach ($treasuries as $treasury)
<tr>
<td></td>
<td>{{ $treasury->available_for_use_month}}</td>
</tr>
#endforeach
<tr>
<td>Total</td>
<td>{{ \App\Models\Treasury::sum('available_for_use_month') }}
</tr>
</table>
in this case what i want to do is connect the total of treasury to emphyas
<tr>
<td>Total</td>
<td>{{ \App\Models\Emphaya::sum('available_for_use_month') + \App\Models\Treasury::sum('available_for_use_month') }}
</tr>
I'm facing an issue with checking the checkbox on the edit page using Livewire. I've tried many ways but still not able to check the old selected value
View Code:
<table id="branches" class="table table-bordered table-sm" width="100%" cellspacing="0">
<thead>
<tr>
<th width="10%">
</th>
<th>Branch ID</th>
</tr>
</thead>
<tbody>
#foreach ($propertiesOptions as $key => $property)
<tr>
<td>
<input class="branchCheckbox"
type="checkbox"
wire:model="propertyIds.{{$property->id}}"
value="{{$property->id}}" #if(in_array($property->id,$propertyIds)) checked #endif>
</td>
<td>{{$property->id}}</td>
</tr>
#endforeach
</tbody>
</table>
Backend Code:
public $propertyIds, $propertiesOptions;
public function mount($record)
{
$this->propertiesOptions = Properties::where('merchant_id',$record->id)->get()
$this->propertyIds = $record->properties->pluck('property_id')->toArray();
}```
updated
And can you check if this correct? wire:model="propertyIds.{{$property->id}}"? Try to delete the wire:model .
<input class="branchCheckbox" type="checkbox"
value="{{$property->id}}"
#if(in_array($property->id,$propertyIds)) checked #endif>
`<table id="branches" class="table table-bordered table-sm" width="100%" cellspacing="0">
<thead>
<tr>
<th width="10%">
</th>
<th>Branch ID</th>
</tr>
</thead>
<tbody>
#foreach ($propertiesOptions as $key => $property)
<tr>
<td>
<input class="branchCheckbox"
type="checkbox"
wire:model="propertyIds"
value="{{$property->id}}" >
</td>
<td>{{$property->id}}</td>
</tr>
#endforeach
</tbody>
</table>`
BACKEND
public $propertyIds, $propertiesOptions;
public function mount($record)
{
$this->propertiesOptions = Properties::where('merchant_id',$record->id)->get()
$this->propertyIds = $record->properties->pluck('property_id')->toArray();
}
In our application, we have modules called Reports where in this report will show you the summarize of the module.
Example
General Journal Report - in this report will show you the summarize of the general journal module.
Now in our reports need to implement the pagination, having a problem applying the pagination in query builder.
Controller
$general_journals = GeneralJournalReportModel::getGeneralJournals();
$data['defined_gj'] = GeneralJournalReportItemsController::getDefinedGJById($general_journals);
I fetch all the general journal records and stored it in the variable general_journals then I passed it in another controller to do something else(such as putting some error handling when the column is null).
Model
public static function getGeneralJournals()
{
return DB::table('general_journals as gj')
->select('gj.id as id',
'gj.number as number',
'gj.posting_date as posting_date',
'gj.remarks as remarks',
'gj.document_reference as document_reference',
'gji.debit_amount as debit_amount',
'gji.credit_amount as credit_amount')
->leftJoin('general_journal_items as gji', 'gj.id', '=', 'gji.general_journal_id')
->where('gj.company_id', Auth::user()->company_id)
->where('gj.approval_status', 3)
->orderBy('gj.id', 'desc')
->simplePaginate(5);
}
View
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12 col-lg-12">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover general-journal-report-table" id="gj-report">
<thead class="thead-global">
<tr>
<th id="pj_sequence">Sequence No.</th>
<th id="pj_date">Posting Date</th>
<th id="pj_op">Transaction No.</th>
<th id="4">Document Reference</th>
<th id="5">Remarks</th>
<th id="6">Amount Due</th>
</tr>
</thead>
<tbody class="general-journal-report-details">
#if($defined_gj)
<?php $counter = 0; ;?>
<?php $total_debit = 0; ?>
#foreach($defined_gj as $key => $value)
<?php $counter++;?>
<?php $total_debit += $value->debit ;?>
<tr>
<td class="pj_sequence">{{$counter}}</td>
<td class="pj_date">{{$value->posting_date}}</td>
<td class="pj_op">{!! $value->number !!}</td>
<td>{{$value->doc_ref}}</td>
<td>{{$value->remarks}}</td>
#if($value->debit == '0')
<td></td>
#else
<td align="right"> {{number_format($value->debit,2)}}</td>
#endif
</tr>
#endforeach
<tr>
<td><b>Total</b></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td align="right"> {{number_format($total_debit)}}</td>
</tr>
#endif
</tbody>
</table>
</div>
{{ $general_journals->links() }}
</div>
When I used the links() my button doesn't have any class.
Question: How do I put some class on the button of links?
NOTE: I tried this {{ $general_journals->links() }} but it only worked on the previous button(I want to also apply the class in the next button)
Try this
{{ $general_journals->links('pagination::bootstrap-4') }}
Replace with your laravel bootstrap version.
If you want to customize the pagination view, you can follow to this link https://laravel.com/docs/5.7/pagination#customizing-the-pagination-view
Below shows my data. I am trying to loop Item inside table <td> tag so that it forms two items in one column.
user
>"name":"Bob"
>"id":1
>"Item":
>"name":"Desk"
>"name":"Chair"
Code
<table class="table table-hover">
<tbody>
<tr>
<th>Name</th>
<th>Items</th>
</tr>
<tr v-for="use in user.data" :key="use.id">
<td>{{ use.name }}</td>
<td v-for="a in use.item">
{{ a.name }},
</td>
</tr>
</tbody>
</table>
But when I do the codes above, it produce another column just like below picture. How do I put the Desk and Chair sits together in one column?
Hi just use a span tag in side td here is my solution, p or div tag are block tags, if you are using bootstrap 4 just set class to span inline-block or inline
<table class="table table-hover">
<tbody>
<tr>
<th>Name</th>
<th>Items</th>
</tr>
<tr v-for="use in user.data" :key="use.id">
<td>{{ use.name }}</td>
<td>
<span v-for="a in use.item"> {{ a.name }}, </span>
</td>
</tr>
</tbody>
</table>
v-for crates another elemenrs for you in each iteration. Use join function to display together
<tr v-for="use in user.data" :key="use.id">
<td>{{ use.name }}</td>
<td>
{{ use.item.join(", ") }},
</td>
</tr>
Output would be Desk, Chair
We can do this with using lodash
`
<tr v-for="use in user.data" :key="use.id">
<td>{{ use.name }}</td>
<td>
{{ _.map(use.item, 'name').join(", ") }}
</td>
</tr>
`
I am using Laravel pagination from controller to paginate some list of data in a table. The pagination numbers are only displaying on the bottom of the table. How do i get to display the numbers on the top of the table as well?
my view:
<table>
<thead>
<tr>
<th>Make</th>
<th>Model</th>
</tr>
</thead>
<tbody>
#foreach ($cars as $car)
<tr>
<td>{{$car->make}}</td>
<td>{{$car->model}}</td>
</tr>
#endforeach
</tbody>
</table>
<div class="pull-right">
{{ $cars->links() }}
</div>
If you copy {{ $cars->links() }} at the top, it will also show you the same pagination like button. It looks like the following
<div class="pull-right">
{{ $cars->links() }}
</div>
<table>
<thead>
<tr>
<th>Make</th>
<th>Model</th>
</tr>
</thead>
<tbody>
#foreach ($cars as $car)
<tr>
<td>{{$car->make}}</td>
<td>{{$car->model}}</td>
</tr>
#endforeach
</tbody>
</table>
<div class="pull-right">
{{ $cars->links() }}
</div>
$cars->links() generates pagination button/links.
You can move it to wherever you like:
<div class="pull-right">
{{ $cars->links() }}
</div>
<table>
<thead>
<tr>
<th>Make</th>
<th>Model</th>
</tr>
</thead>
<tbody>
#foreach ($cars as $car)
<tr>
<td>{{$car->make}}</td>
<td>{{$car->model}}</td>
</tr>
#endforeach
</tbody>
</table>
use this on the top as well
<div class="pull-right">
{{ $cars->links() }}
</div>