Skip to content

Commit

Permalink
Use new models & modelsPaginated distinction to get access to both
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Dec 13, 2024
1 parent 20a9fc0 commit a1a9a8f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions config/sections/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@
$files = $files->flip();
}

return $files;
},
'modelsPaginated' => function () {
// apply the default pagination
$files = $files->paginate([
return $this->models()->paginate([
'page' => $this->page,
'limit' => $this->limit,
'method' => 'none' // the page is manually provided
]);

return $files;
},
'files' => function () {
return $this->models;
Expand All @@ -110,7 +111,7 @@
// a different parent model
$dragTextAbsolute = $this->model->is($this->parent) === false;

foreach ($this->models as $file) {
foreach ($this->modelsPaginated() as $file) {
$panel = $file->panel();
$permissions = $file->permissions();

Expand Down Expand Up @@ -145,7 +146,7 @@
return $data;
},
'total' => function () {
return $this->models->pagination()->total();
return $this->models()->count();
},
'errors' => function () {
$errors = [];
Expand Down
11 changes: 6 additions & 5 deletions config/sections/pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,25 +150,26 @@
$pages = $pages->flip();
}

return $pages;
},
'modelsPaginated' => function () {
// pagination
$pages = $pages->paginate([
return $this->models()->paginate([
'page' => $this->page,
'limit' => $this->limit,
'method' => 'none' // the page is manually provided
]);

return $pages;
},
'pages' => function () {
return $this->models;
},
'total' => function () {
return $this->models->pagination()->total();
return $this->models()->count();
},
'data' => function () {
$data = [];

foreach ($this->models as $page) {
foreach ($this->modelsPaginated() as $page) {
$panel = $page->panel();
$permissions = $page->permissions();

Expand Down

0 comments on commit a1a9a8f

Please sign in to comment.