1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Revised webhooks list to new format

Also aligned query naming to start with model in use.
Also added created/updated sort options to roles.
This commit is contained in:
Dan Brown
2022-10-30 12:02:06 +00:00
parent 98b59a1024
commit f75091a1c5
12 changed files with 123 additions and 40 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace BookStack\Actions\Queries;
use BookStack\Actions\Webhook;
use Illuminate\Pagination\LengthAwarePaginator;
/**
* Get all the webhooks in the system in a paginated format.
*/
class WebhooksAllPaginatedAndSorted
{
/**
* @param array{sort: string, order: string, search: string} $sortData
*/
public function run(int $count, array $sortData): LengthAwarePaginator
{
$sort = $sortData['sort'];
$query = Webhook::query()->select(['*'])
->withCount(['trackedEvents'])
->orderBy($sort, $sortData['order']);
if ($sortData['search']) {
$term = '%' . $sortData['search'] . '%';
$query->where(function ($query) use ($term) {
$query->where('name', 'like', $term)
->orWhere('endpoint', 'like', $term);
});
}
return $query->paginate($count);
}
}