From d6dbc26e4071cdad35d9d2deda9d4dc38d352959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Fri, 6 Dec 2024 11:09:55 +0100 Subject: [PATCH] wip --- resources/views/resources/relation.blade.php | 2 +- src/Fields/Relation.php | 1 - src/Root.php | 2 +- src/RootServiceProvider.php | 8 +++++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/views/resources/relation.blade.php b/resources/views/resources/relation.blade.php index 74c74fda..f30f6289 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/src/Fields/Relation.php b/src/Fields/Relation.php index 050bf9c4..bbb20932 100644 --- a/src/Fields/Relation.php +++ b/src/Fields/Relation.php @@ -927,7 +927,6 @@ public function toSubResource(Request $request, Model $model): array { return array_merge($this->toArray(), [ 'key' => $this->modelAttribute, - 'createUrl' => sprintf('%s/create', $this->modelUrl($model)), 'baseUrl' => $this->modelUrl($model), 'url' => URL::query($this->modelUrl($model), $this->parseQueryString($request->fullUrl())), 'modelName' => $this->getRelatedName(), diff --git a/src/Root.php b/src/Root.php index 2fe01604..8c0785dd 100644 --- a/src/Root.php +++ b/src/Root.php @@ -24,7 +24,7 @@ class Root * * @var string */ - public const VERSION = '2.5.2'; + public const VERSION = '2.5.3'; /** * The registered booting callbacks. diff --git a/src/RootServiceProvider.php b/src/RootServiceProvider.php index aad888b8..eec52ba3 100644 --- a/src/RootServiceProvider.php +++ b/src/RootServiceProvider.php @@ -2,6 +2,7 @@ namespace Cone\Root; +use Cone\Root\Exceptions\ResourceResolutionException; use Cone\Root\Exceptions\SaveFormDataException; use Cone\Root\Models\Medium; use Cone\Root\Models\User; @@ -25,6 +26,7 @@ use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\Facades\Redirect; use Illuminate\Support\ServiceProvider; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class RootServiceProvider extends ServiceProvider { @@ -142,7 +144,11 @@ protected function registerRoutes(): void $root = $this->app->make(Root::class); $this->app['router']->bind('resource', function (string $key) use ($root): Resource { - return $root->resources->resolve($key); + try { + return $root->resources->resolve($key); + } catch (ResourceResolutionException $exception) { + throw new NotFoundHttpException(); + } }); $this->app['router']->bind('resourceModel', function (string $id, Route $route): Model {