Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Nov 22, 2024
1 parent 9ec542c commit 8fdff9e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion resources/views/resources/relation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</h2>
<div class="app-card__actions">
@if($abilities['create'])
<a href="{{ $url }}/create" class="btn btn--primary btn--icon" data-turbo-frame="_top">
<a href="{{ $createUrl }}" class="btn btn--primary btn--icon" data-turbo-frame="_top">
<x-root::icon name="plus" class="btn__icon" />
{{ __('Add :resource', ['resource' => $modelName]) }}
</a>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/table/filters.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class="btn btn--light btn--icon btn--counter data-table-filter__toggle"
<button type="submit" class="btn btn--primary btn--sm">
{{ __('Filter') }}
</button>
<a href="{{ $url }}" class="btn btn--light btn--sm">
<a href="{{ $baseUrl }}" class="btn btn--light btn--sm">
{{ __('Reset') }}
</a>
</div>
Expand Down
7 changes: 4 additions & 3 deletions src/Fields/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ public function registerRouteConstraints(Request $request, Router $router): void
/**
* Parse the given query string.
*/
protected function parseQueryString(string $url): array
public function parseQueryString(string $url): array
{
$query = parse_url($url, PHP_URL_QUERY);

Expand Down Expand Up @@ -927,7 +927,9 @@ public function toSubResource(Request $request, Model $model): array
{
return array_merge($this->toArray(), [
'key' => $this->modelAttribute,
'url' => $this->modelUrl($model),
'createUrl' => sprintf('%s/create', $this->modelUrl($model)),
'baseUrl' => $this->modelUrl($model),
'url' => URL::query($this->modelUrl($model), $this->parseQueryString($request->fullUrl())),
'modelName' => $this->getRelatedName(),
'abilities' => $this->mapRelationAbilities($request, $model),
]);
Expand Down Expand Up @@ -965,7 +967,6 @@ public function toIndex(Request $request, Model $model): array
})
->all(),
'activeFilters' => $this->resolveFilters($request)->active($request)->count(),
'url' => URL::query($this->modelUrl($model), $this->parseQueryString($request->server('HTTP_REFERER', $request->url()))),
'parentUrl' => URL::query($request->server('HTTP_REFERER'), $request->query()),
]);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use Throwable;

Expand Down Expand Up @@ -612,6 +613,7 @@ public function toArray(): array
'name' => $this->getName(),
'uriKey' => $this->getUriKey(),
'url' => $this->getUri(),
'baseUrl' => $this->getUri(),
];
}

Expand Down Expand Up @@ -703,7 +705,7 @@ public function toShow(Request $request, Model $model): array
->authorized($request, $model)
->map(static function (Relation $relation) use ($request, $model): array {
return array_merge($relation->toSubResource($request, $model), [
'url' => trim(sprintf('%s?%s', $relation->modelUrl($model), $request->getQueryString()), '?'),
'url' => URL::query($relation->modelUrl($model), $relation->parseQueryString($request->fullUrl())),
]);
}),
'abilities' => array_merge(
Expand Down
2 changes: 1 addition & 1 deletion src/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Root
*
* @var string
*/
public const VERSION = '2.5.1';
public const VERSION = '2.5.2';

/**
* The registered booting callbacks.
Expand Down

0 comments on commit 8fdff9e

Please sign in to comment.