Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Dec 6, 2024
1 parent 5d2a79c commit d6dbc26
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 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="{{ $createUrl }}" class="btn btn--primary btn--icon" data-turbo-frame="_top">
<a href="{{ $baseUrl }}/create" 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
1 change: 0 additions & 1 deletion src/Fields/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
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.2';
public const VERSION = '2.5.3';

/**
* The registered booting callbacks.
Expand Down
8 changes: 7 additions & 1 deletion src/RootServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d6dbc26

Please sign in to comment.