findOrFail($request->integer('property')); $current->select($property); return redirect()->to($this->target($request->input('return', url()->previous()), $property)); } private function target(string $previous, Property $property): string { $fallback = route('filament.admin.pages.dashboard'); if (! Str::startsWith($previous, url('/admin'))) { return $fallback; } try { $route = Route::getRoutes()->match(Request::create($previous)); } catch (HttpException) { return $fallback; } $name = (string) $route->getName(); if (Str::startsWith($name, 'filament.admin.resources.properties.')) { return PropertyResource::getUrl('edit', ['record' => $property]); } if (Str::endsWith($name, ['.edit', '.view'])) { $index = Str::beforeLast($name, '.').'.index'; return Route::has($index) ? route($index) : $fallback; } // A page's own apartment parameter would undo the switch. $query = []; parse_str((string) parse_url($previous, PHP_URL_QUERY), $query); unset($query['wohnung']); return strtok($previous, '?').($query !== [] ? '?'.http_build_query($query) : ''); } }