This is the most important part of this boilerplate. We can generate table with server side pagination very easily with Laravel premio. Just follow the below steps:
Assume we are going to fecth Page
model data.
public function index(Request $request)
{
$pages = Page::paginate(10);
return view('admin.page.index',compact('pages');
}
Now generate table in your page index page like this
<x-app-component>
<x-page.page-title data="Pages" />
<x-slot name="content">
<div class="card">
<div class="card-body table-responsive">
@if (count($pages))
{!! generate_table($pages->toArray()['data'], [
'attributes' => ['class' => 'table your-custom-class-name'],
'column' => ['id', 'name', 'created_at'],
'action' => 'admin.database._action', //path will be resources/views/admin/database._action.blade.php
]) !!}
@else
<p class="text-center fw-bold">No page found.</p>
@endif
</div>
</div>
</x-slot>
</x-app-component>
Now create your action button to edit, delete what ever you want like this:
<a
href="{{ route('page.edit',array($item['id'])) }}"
class="btn btn-primary btn-sm py-0">
Edit
</a>