user(); assert($viewer !== null); Gate::forUser($viewer)->authorize('view', $file); if ($viewer->isStaff()) { // The file's own page, which is also where the activity log's // "View" link lands — one destination for "show me this // conversation" rather than two. It works whatever page of the // library the file happens to be on, which the slide-over did // not. return redirect()->route('files.edit', [$file, 'tab' => 'comments']); } // The portal is a list, so this opens the file's own comment panel // from its row. A file that is not on the page the client lands on // (deep in a folder, or past the first page) simply does not open — // they still arrive somewhere sensible, which is why this is a // query parameter rather than a promise. return redirect()->route('my-files.index', ['comments' => $file->id]); } }