Skip to content

Commit

Permalink
fix: adding panel name
Browse files Browse the repository at this point in the history
  • Loading branch information
rupadana committed Mar 10, 2024
1 parent ca0230a commit c535d95
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Rupadana\ApiService\Exceptions\InvalidTenancyConfiguration;

Route::prefix('api')
->name('api')
->name('api.')
->group(function () {
if (ApiService::tenancyAwareness() && (! ApiService::isRoutePrefixedByPanel() || ! ApiService::isTenancyEnabled())) {
throw new InvalidTenancyConfiguration("Tenancy awareness is enabled!. Please set 'api-service.route.panel_prefix=true' and 'api-service.tenancy.enabled=true'");
Expand All @@ -21,14 +21,15 @@
$tenantRoutePrefix = $panel->getTenantRoutePrefix();
$tenantSlugAttribute = $panel->getTenantSlugAttribute();
$panelRoutePrefix = ApiService::isRoutePrefixedByPanel() ? '{panel}' : '';
$panelNamePrefix = $panelRoutePrefix ? $panel->getId() . '.' : '';

if (
$hasTenancy &&
ApiService::isTenancyEnabled() &&
ApiService::tenancyAwareness()
) {
Route::prefix($panelRoutePrefix . '/' . (($tenantRoutePrefix) ? "{$tenantRoutePrefix}/" : '') . '{tenant' . (($tenantSlugAttribute) ? ":{$tenantSlugAttribute}" : '') . '}')
->name($panelRoutePrefix . '.')
->name($panelNamePrefix)
->group(function () use ($panel) {
$apiServicePlugin = $panel->getPlugin('api-service');
$apiServicePlugin->route($panel);
Expand All @@ -37,7 +38,7 @@

if (! ApiService::tenancyAwareness()) {
Route::prefix($panelRoutePrefix)
->name($panelRoutePrefix . '.')
->name($panelNamePrefix)
->group(function () use ($panel) {
$apiServicePlugin = $panel->getPlugin('api-service');
$apiServicePlugin->route($panel);
Expand Down

0 comments on commit c535d95

Please sign in to comment.