user pagination
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $users
|
||||
* @var int $page_id
|
||||
*/
|
||||
|
||||
use app\models\User;
|
||||
@ -12,7 +13,9 @@ use Itguild\Tables\ListJsonTable;
|
||||
use kernel\IGTabel\btn\PrimaryBtn;
|
||||
use kernel\IGTabel\ListJsonTableEloquentCollection;
|
||||
|
||||
$dataProvider = new ListJsonTableEloquentCollection($users, [
|
||||
$perPage = 3;
|
||||
$chunks = $users->forPage($page_id, $perPage);
|
||||
$dataProvider = new ListJsonTableEloquentCollection($chunks, [
|
||||
'model' => User::class,
|
||||
'perPage' => 5,
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
@ -23,8 +26,8 @@ $table->beforePrint(function () {
|
||||
return PrimaryBtn::create("Создать", "/admin/user/create")->fetch();
|
||||
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
|
||||
});
|
||||
$table->afterPrint(function () use ($users) {
|
||||
$pagination = new \Itguild\Tables\Pagination($users->count(), 5, 1, "/admin/user/");
|
||||
$table->afterPrint(function () use ($page_id, $users, $perPage) {
|
||||
$pagination = new \Itguild\Tables\Pagination($users->count(), $perPage, $page_id, "/admin/user/page");
|
||||
$pagination->create();
|
||||
return $pagination->fetch();
|
||||
});
|
||||
|
Reference in New Issue
Block a user