Updated API code.

This commit is contained in:
James Cole
2021-03-05 07:03:28 +01:00
parent b0d4ebbf4b
commit 30d653faee
24 changed files with 521 additions and 78 deletions

View File

@@ -565,4 +565,19 @@ class RuleRepository implements RuleRepositoryInterface
return implode(' ', $params);
}
/**
* @inheritDoc
*/
public function searchRule(string $query, int $limit): Collection
{
$search = $this->user->rules();
if ('' !== $query) {
$search->where('rules.title', 'LIKE', sprintf('%%%s%%', $query));
}
$search->orderBy('rules.order', 'ASC')
->orderBy('rules.title', 'ASC');
return $search->take($limit)->get(['id','title','description']);
}
}

View File

@@ -39,6 +39,14 @@ interface RuleRepositoryInterface
*/
public function count(): int;
/**
* @param string $query
* @param int $limit
*
* @return Collection
*/
public function searchRule(string $query, int $limit): Collection;
/**
* Return search query for rule.
*