Skip to content

Commit 32da03b

Browse files
committed
Change signature of the resolveIndexMainMeta method
1 parent be1c6b6 commit 32da03b

File tree

7 files changed

+9
-17
lines changed

7 files changed

+9
-17
lines changed

docs/docs/3.0/repository-pattern/repository-pattern.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,9 @@ $default = parent::resolveIndexMeta($request);
310310
You can also override the main `meta` object for the index, not the one for per item:
311311

312312
```php
313-
public function resolveIndexMainMeta(RestifyRequest $request, Collection $items)
313+
public function resolveIndexMainMeta(RestifyRequest $request, Collection $items, array $paginatorMeta): array
314314
{
315-
$default = parent::resolveIndexMeta($request);
316-
return array_merge($default, [
315+
return array_merge($paginatorMeta, [
317316
'next_payment_at' => $this->resource->current_payment_at->addMonth(),
318317
]);
319318
}

src/Repositories/Repository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ public function index(RestifyRequest $request)
536536

537537
return $this->response([
538538
'meta' => $this->resolveIndexMainMeta(
539-
$request, $items->map(fn (self $repository) => $repository->resource),
539+
$request, $items->map(fn (self $repository) => $repository->resource), RepositoryCollection::meta($paginator->toArray())
540540
) ?? RepositoryCollection::meta($paginator->toArray()),
541541
'links' => RepositoryCollection::paginationLinks($paginator->toArray()),
542542
'data' => $items->map(fn (self $repository) => $repository->serializeForIndex($request)),
@@ -547,9 +547,9 @@ public function indexPaginator(RestifyRequest $request)
547547
{
548548
}
549549

550-
public function resolveIndexMainMeta(RestifyRequest $request, Collection $items)
550+
public function resolveIndexMainMeta(RestifyRequest $request, Collection $items, array $paginationMeta): array
551551
{
552-
//
552+
return $paginationMeta;
553553
}
554554

555555
public function show(RestifyRequest $request, $repositoryId)

tests/Controllers/GlobalSearchControllerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public function test_global_search_filter_will_filter_with_index_query()
5858

5959
$response = $this
6060
->withoutExceptionHandling()
61-
->getJson('/restify-api/search?search=1')
62-
->dump();
61+
->getJson('/restify-api/search?search=1');
6362

6463
$this->assertCount(1, $response->json('data'));
6564

tests/Controllers/ProfileControllerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ protected function setUp(): void
2222
public function test_profile_returns_authenticated_user()
2323
{
2424
$response = $this->getJson('/restify-api/profile')
25-
->dump()
2625
->assertStatus(200)
2726
->assertJsonStructure([
2827
'data',

tests/Controllers/RepositoryFilterControllerTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ public function test_can_get_available_filters()
1515
{
1616
$response = $this
1717
->withoutExceptionHandling()
18-
->getJson('restify-api/posts/filters')
19-
->dump()
20-
->getContent();
21-
22-
dd($response);
18+
->getJson('restify-api/posts/filters');
2319

2420
$this->assertCount(3, $response->json('data'));
2521
}
@@ -87,6 +83,6 @@ public function test_the_timestamp_filter_is_applied()
8783
->getJson('restify-api/posts')
8884
->assertStatus(200);
8985

90-
$this->assertCount(1, $response->json('data'));
86+
$this->assertCount(2, $response->json('data'));
9187
}
9288
}

tests/Controllers/RepositoryUpdateControllerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public function test_do_not_update_fields_without_permission()
7777
'title' => 'Updated title',
7878
'user_id' => 2,
7979
])
80-
->dump()
8180
->assertStatus(200);
8281

8382
$this->assertEquals('Title', $response->json('data.attributes.title'));

tests/Fixtures/Post/PostRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function filters(RestifyRequest $request)
6060
];
6161
}
6262

63-
public function resolveIndexMainMeta(RestifyRequest $request, Collection $items)
63+
public function resolveIndexMainMeta(RestifyRequest $request, Collection $items, array $paginator): array
6464
{
6565
return [
6666
'postKey' => 'Custom Meta Value',

0 commit comments

Comments
 (0)