diff --git a/config/filament-fabricator.php b/config/filament-fabricator.php index 8081dcb..010f18e 100644 --- a/config/filament-fabricator.php +++ b/config/filament-fabricator.php @@ -4,6 +4,7 @@ return [ 'routing' => [ 'enabled' => true, + 'prefix' => null // /pages ], 'layouts' => [ diff --git a/routes/web.php b/routes/web.php index 64aa41b..266b132 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,7 +6,7 @@ use Z3d0X\FilamentFabricator\Facades\FilamentFabricator; if (config('filament-fabricator.routing.enabled')) { - Route::middleware(SubstituteBindings::class)->group(function () { + Route::middleware(SubstituteBindings::class)->prefix(config('filament-fabricator.routing.prefix', null))->group(function () { Route::get('/{filamentFabricatorPage?}', function ($filamentFabricatorPage = null) { // Handle root (home) page if (blank($filamentFabricatorPage)) { diff --git a/src/Resources/PageResource.php b/src/Resources/PageResource.php index 2f14314..71f8286 100644 --- a/src/Resources/PageResource.php +++ b/src/Resources/PageResource.php @@ -56,12 +56,12 @@ public static function form(Form $form): Form ->schema([ Placeholder::make('page_url') ->visible(fn ($record) => filled($record)) - ->content(fn ($record) => FilamentFabricator::getPageUrlFromId($record?->id, true)), + ->content(fn ($record) => config('filament-fabricator.routing.prefix') . FilamentFabricator::getPageUrlFromId($record?->id, true)), TextInput::make('title') ->label(__('filament-fabricator::page-resource.labels.title')) ->afterStateUpdated(function (Closure $get, Closure $set, ?string $state, ?Model $record) { - if (! $get('is_slug_changed_manually') && filled($state) && blank($record)) { + if (!$get('is_slug_changed_manually') && filled($state) && blank($record)) { $set('slug', Str::slug($state)); } }) @@ -148,7 +148,7 @@ public static function table(Table $table): Table EditAction::make(), Action::make('visit') ->label(__('filament-fabricator::page-resource.actions.visit')) - ->url(fn ($record) => FilamentFabricator::getPageUrlFromId($record->id, true)) + ->url(fn ($record) => config('filament-fabricator.routing.prefix') . FilamentFabricator::getPageUrlFromId($record->id, true)) ->icon('heroicon-o-external-link') ->openUrlInNewTab() ->color('success') diff --git a/src/Resources/PageResource/Pages/EditPage.php b/src/Resources/PageResource/Pages/EditPage.php index e458876..1bc5a5e 100644 --- a/src/Resources/PageResource/Pages/EditPage.php +++ b/src/Resources/PageResource/Pages/EditPage.php @@ -19,7 +19,7 @@ protected function getActions(): array Actions\DeleteAction::make(), Action::make('visit') ->label(__('filament-fabricator::page-resource.actions.visit')) - ->url(fn () => FilamentFabricator::getPageUrlFromId($this->record->id, true)) + ->url(fn () => config('filament-fabricator.routing.prefix') . FilamentFabricator::getPageUrlFromId($this->record->id, true)) ->icon('heroicon-o-external-link') ->openUrlInNewTab() ->color('success') diff --git a/src/Resources/PageResource/Pages/ViewPage.php b/src/Resources/PageResource/Pages/ViewPage.php index 361e18f..44aa79e 100644 --- a/src/Resources/PageResource/Pages/ViewPage.php +++ b/src/Resources/PageResource/Pages/ViewPage.php @@ -18,7 +18,7 @@ protected function getActions(): array Actions\EditAction::make(), Action::make('visit') ->label(__('filament-fabricator::page-resource.actions.visit')) - ->url(fn () => FilamentFabricator::getPageUrlFromId($this->record->id, true)) + ->url(fn () => config('filament-fabricator.routing.prefix') . FilamentFabricator::getPageUrlFromId($this->record->id, true)) ->icon('heroicon-o-external-link') ->openUrlInNewTab() ->color('success')