Skip to content

Commit

Permalink
Urls
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Aug 17, 2022
1 parent 2f3cecb commit a353f90
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Extracts/Extract.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public function mapItems(ExtractRequest $request): array
->latest()
->paginate($request->input('per_page'))
->withQueryString()
->setPath($this->getUri())
->through(function (Model $model) use ($request): array {
return (new ModelResource($model))->toDisplay(
$request, $this->resolveFields($request)->available($request, $model)
Expand Down
1 change: 1 addition & 0 deletions src/Fields/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public function mapItems(ResourceRequest $request, Model $model): array
->latest()
->paginate($request->input('per_page'))
->withQueryString()
->setPath($this->getUri())
->through(function (Model $related) use ($request, $model): array {
return $this->mapOption($request, $model, $related);
})
Expand Down
2 changes: 2 additions & 0 deletions src/Http/Controllers/NotificationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Cone\Root\Http\Requests\RootRequest;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\URL;

class NotificationsController extends Controller
{
Expand All @@ -20,6 +21,7 @@ public function index(RootRequest $request): JsonResponse
->filter($request)
->latest()
->paginate($request->input('per_page'))
->setPath(URL::route('root.api.notifications.index', [], false))
->withQueryString();

return new JsonResponse(array_merge($notifications->toArray(), [
Expand Down
1 change: 1 addition & 0 deletions src/Http/Controllers/RelationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function __invoke(ResourceRequest $request): JsonResponse
}
})
->paginate()
->setPath($field->getUri())
->through(static function (Model $related) use ($request, $model, $field): array {
return $field->mapOption($request, $model, $related);
});
Expand Down
1 change: 1 addition & 0 deletions src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public function mapItems(ResourceRequest $request): array
->latest()
->paginate($request->input('per_page'))
->withQueryString()
->setPath($this->getUri())
->through(function (Model $model) use ($request): array {
return $this->mapItem($request, $model)->toDisplay(
$request, $this->resolveFields($request)->available($request, $model)
Expand Down
2 changes: 1 addition & 1 deletion src/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class Root
*
* @var string
*/
public const VERSION = '0.8.2';
public const VERSION = '0.8.3';

/**
* The registered callbacks.
Expand Down
1 change: 1 addition & 0 deletions src/Traits/AsSubResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function mapItems(ResourceRequest $request, Model $model): array

$items = $relation->paginate($request->input('per_page'))
->withQueryString()
->setPath($this->getUri())
->through(function (Model $related) use ($request, $model): array {
return $this->mapItem($request, $model, $related)->toDisplay(
$request, $this->resolveFields($request)->available($request, $model, $related)
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/Controllers/NotificationsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function a_notifications_controller_has_index()
$this->actingAs($this->admin)
->get('/root/api/notifications')
->assertOk()
->assertJson($this->admin->notifications()->paginate()->toArray());
->assertJson($this->admin->notifications()->paginate()->setPath('/root/api/notifications')->toArray());
}

/** @test */
Expand Down
1 change: 1 addition & 0 deletions tests/Http/Controllers/RelationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function a_relation_controller_has_index()
$results = $this->field
->resolveQuery($this->request, $model)
->paginate()
->setPath('/root/posts/fields/author')
->through(function ($related) use ($model): array {
return $this->field->mapOption($this->request, $model, $related);
});
Expand Down

0 comments on commit a353f90

Please sign in to comment.