Skip to content

Commit

Permalink
Merge pull request #34 from rupadana/dev
Browse files Browse the repository at this point in the history
fix: adding panel name
  • Loading branch information
rupadana authored Mar 10, 2024
2 parents e110f01 + c535d95 commit 4b78c09
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 4b78c09

Please sign in to comment.