- Multiple bugfixe linked to query fragments

- Added a new SearchRequest package to handle search request efficiently
This commit is contained in:
Dave Mc Nicoll committed 2020-03-28 22:13:29 -04:00
1 parent 4b29232543
commit 938639a590
15 files changed
+148 -27

No files matched your search

@@ -0,0 +1,17 @@
<?php
namespace Ulmus\SearchRequest;
interface SearchRequestInterface {
public function wheres() : iterable;
public function likes() : iterable;
public function orders() : iterable;
public function groups() : iterable;
public function limit() : int;
public function offset() : int;
}
@@ -0,0 +1,28 @@
<?php
namespace Ulmus\SearchRequest;
trait SearchRequestPaginationTrait {
public int $count = 0;
public int $page = 1;
public int $pageCount = 0;
public function pagination(int $page, int $itemCount) : void
{
$this->count = $itemCount;
$this->page = $page;
}
public function pageCount() : int
{
return ceil($this->count / $this->limit());
}
public function hasPagination() : int
{
return $this->pageCount() > 1;
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace Ulmus\SearchRequest;
use \Psr\Http\Message\ServerRequestInterface;
interface SearchableInterface {
public static function searchRequest(ServerRequestInterface $request) : SearchRequestInterface;
}