diff --git a/resources/views/resources/relation.blade.php b/resources/views/resources/relation.blade.php index 8aff59de..74c74fda 100644 --- a/resources/views/resources/relation.blade.php +++ b/resources/views/resources/relation.blade.php @@ -6,7 +6,7 @@
@if($abilities['create']) - + {{ __('Add :resource', ['resource' => $modelName]) }} diff --git a/resources/views/table/filters.blade.php b/resources/views/table/filters.blade.php index 9a2d0aef..13f16a89 100644 --- a/resources/views/table/filters.blade.php +++ b/resources/views/table/filters.blade.php @@ -21,7 +21,7 @@ class="btn btn--light btn--icon btn--counter data-table-filter__toggle" - + {{ __('Reset') }}
diff --git a/src/Fields/Relation.php b/src/Fields/Relation.php index c51b98ba..050bf9c4 100644 --- a/src/Fields/Relation.php +++ b/src/Fields/Relation.php @@ -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); @@ -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), ]); @@ -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()), ]); } diff --git a/src/Resources/Resource.php b/src/Resources/Resource.php index b2d1e919..82197ccb 100644 --- a/src/Resources/Resource.php +++ b/src/Resources/Resource.php @@ -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; @@ -612,6 +613,7 @@ public function toArray(): array 'name' => $this->getName(), 'uriKey' => $this->getUriKey(), 'url' => $this->getUri(), + 'baseUrl' => $this->getUri(), ]; } @@ -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( diff --git a/src/Root.php b/src/Root.php index 2b0d2e81..2fe01604 100644 --- a/src/Root.php +++ b/src/Root.php @@ -24,7 +24,7 @@ class Root * * @var string */ - public const VERSION = '2.5.1'; + public const VERSION = '2.5.2'; /** * The registered booting callbacks.