Skip to content

Commit

Permalink
change category limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Mh-Asmi authored and tuxpiper committed Dec 18, 2024
1 parent b9ad839 commit c24b2bb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FetchAllCategoriesQuery implements Query
public static function fromRequest(Request $request): self
{
$query = new self();
$query->setDefaultLimit(1000);
$query->setPaging($request);
$query->setSearchFields(new CategorySearchFields($request));
$query->addOnlyParameteresFromRequest(
Expand Down
4 changes: 3 additions & 1 deletion src/Ushahidi/Modules/V5/Http/Resources/CategoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ public function toArray($request)
'available' => $this->translations->groupBy('language')->keys()
];
}
$data['allowed_privileges']= $this->getResourcePrivileges();
// To Do: this call cause an infinit loop , need to be checked
// note: it was not found before last commit , so it will not disable it it will not affect the work of front end
//$data['allowed_privileges']= $this->getResourcePrivileges();
return $data;
}

Expand Down
30 changes: 22 additions & 8 deletions src/Ushahidi/Modules/V5/Traits/HasPaginate.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ trait HasPaginate
private $paging;
private $default_order;
private $default_sort_by = 'id';
private $default_limit = '20';
private $default_limit = 20;
private $default_page = 1;

public function getPaging(): Paging
{
return $this->paging;
}

public function setPaging(
Request $request,
$default_sort_by = null,
Expand All @@ -29,15 +30,28 @@ public function setPaging(
) {
$this->paging = Paging::fromRequest(
$request,
$default_sort_by,
$default_order,
$default_limit,
$default_page
$default_sort_by ?? $this->default_sort_by,
$default_order ?? $this->default_order,
$default_limit ?? $this->default_limit,
$default_page ?? $this->default_page
);
}

public function setDefaultOrder(): void
public function setDefaultOrder($order): void
{
$this->default_order = $order;
}
public function setDefaultSort($sort): void
{
$this->default_sort_by = $sort;
}
public function setDefaultLimit($limit): void
{
$this->default_limit = $limit;
}

public function setDefaultPage($page): void
{
$this->paging;
$this->page = $page;
}
}

0 comments on commit c24b2bb

Please sign in to comment.