update search
This commit is contained in:
parent
b07369bcf4
commit
aa0f2caaa3
|
@ -87,13 +87,13 @@ class Api
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $payload
|
* @param array<string, mixed> $payload
|
||||||
*
|
*
|
||||||
* @return Collection<int, MemberEntry>
|
* @return LengthAwarePaginator<MemberEntry>
|
||||||
*/
|
*/
|
||||||
public function pageSearch(array $payload, int $page, int $perPage): LengthAwarePaginator
|
public function pageSearch(array $payload, int $page, int $perPage): LengthAwarePaginator
|
||||||
{
|
{
|
||||||
$start = ($page - 1) * $perPage;
|
$start = ($page - 1) * $perPage;
|
||||||
$response = $this->http()->get($this->url.'/ica/rest/nami/search-multi/result-list?searchedValues='.rawurlencode(json_encode((object) $payload) ?: '{}').'&page='.$page.'&start='.$start.'&limit='.$perPage);
|
$response = $this->http()->get($this->url.'/ica/rest/nami/search-multi/result-list?searchedValues='.rawurlencode(json_encode((object) $payload) ?: '{}').'&page='.$page.'&start='.$start.'&limit='.$perPage);
|
||||||
$items = collect($response->json()['data'])->map(fn ($member) => MemberEntry::from($member));
|
$items = array_map(fn ($member) => MemberEntry::from($member), $response->json()['data']);
|
||||||
|
|
||||||
return new LengthAwarePaginator($items, $response->json('totalEntries'), $perPage, $page, []);
|
return new LengthAwarePaginator($items, $response->json('totalEntries'), $perPage, $page, []);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,13 @@ class SearchFake extends Fake
|
||||||
{
|
{
|
||||||
Http::fake(function ($request) use ($page, $start, $data, $perPage) {
|
Http::fake(function ($request) use ($page, $start, $data, $perPage) {
|
||||||
if (Str::endsWith($request->url(), '&page='.$page.'&start='.$start.'&limit='.$perPage)) {
|
if (Str::endsWith($request->url(), '&page='.$page.'&start='.$start.'&limit='.$perPage)) {
|
||||||
return $this->collection(collect($data)->map(fn ($member) => $member));
|
return $this->collection(collect($data));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<int, MemberEntry> $data
|
* @param array<string, string|int> $data
|
||||||
*/
|
*/
|
||||||
public function assertFetched(int $page, int $start, int $perPage, array $data): void
|
public function assertFetched(int $page, int $start, int $perPage, array $data): void
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,9 +14,17 @@ class MemberEntryRequestFactory extends RequestFactory
|
||||||
'lastname' => $this->faker->lastName(),
|
'lastname' => $this->faker->lastName(),
|
||||||
'groupId' => $this->faker->numberBetween(100, 200),
|
'groupId' => $this->faker->numberBetween(100, 200),
|
||||||
'id' => $this->faker->numberBetween(100, 200),
|
'id' => $this->faker->numberBetween(100, 200),
|
||||||
|
'agegroup' => $this->faker->randomElement(['Wölfling', 'Juffi', 'Pfadi', 'Rover']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function noFirstname(): self
|
||||||
|
{
|
||||||
|
return $this->state([
|
||||||
|
'firstname' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $attributes
|
* @param array<string, mixed> $attributes
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue