Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Http/Middleware/RestifyInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public function handle($request, Closure $next)
$request->is(trim($path.'/*', '/')) ||
$request->is('restify-api/*') ||
collect(Restify::$repositories)
->filter(fn($repository) => $repository::prefix())
->some(fn($repository) => $request->is($repository::prefix() . '/*')) ||
->filter(fn ($repository) => $repository::prefix())
->some(fn ($repository) => $request->is($repository::prefix().'/*')) ||
collect(Restify::$repositories)
->filter(fn($repository) => $repository::indexPrefix())
->some(fn($repository) => $request->is($repository::indexPrefix() . '/*'));
->filter(fn ($repository) => $repository::indexPrefix())
->some(fn ($repository) => $request->is($repository::indexPrefix().'/*'));

app()->register(RestifyCustomRoutesProvider::class);

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/InteractWithRepositories.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function repository($key = null): ?Repository

if (! $repository::authorizedToUseRoute($this)) {
throw new UnauthorizedException(__('Unauthorized to use the route :name. Check prefix.', [
'name' => $this->getRequestUri()
'name' => $this->getRequestUri(),
]), 403);
}

Expand Down
9 changes: 3 additions & 6 deletions src/Repositories/WithRoutePrefix.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php


namespace Binaryk\LaravelRestify\Repositories;


use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -61,19 +59,18 @@ public static function authorizedToUseRoute(RestifyRequest $request): bool
return true;
}

return $request->is(static::indexPrefix() . '/*');
return $request->is(static::indexPrefix().'/*');
} else {
// the rest
return $request->is(static::prefix() . '/*');
return $request->is(static::prefix().'/*');
}

}

protected static function shouldAuthorizeRouteUsage(): bool
{
return collect([
static::prefix(),
static::indexPrefix(),
])->some(fn($prefix) => (bool) $prefix);
])->some(fn ($prefix) => (bool) $prefix);
}
}
2 changes: 1 addition & 1 deletion src/RestifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function registerPrefixed($config)
public function registerIndexPrefixed($config)
{
collect(Restify::$repositories)
->filter(fn($repository) => $repository::indexPrefix())
->filter(fn ($repository) => $repository::indexPrefix())
->each(function ($repository) use ($config) {
$config['prefix'] = $repository::indexPrefix();
Route::group($config, function () {
Expand Down