© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
johncarter

How do I redirect a user after login based on the panel they are allowed to view?

I have 2 panels:
class CpPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->default()
            ->id('cp')
            ->path('cp')
//...
class CpPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->default()
            ->id('cp')
            ->path('cp')
//...

class FrontendPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->id('frontend')
            ->path('')
class FrontendPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->id('frontend')
            ->path('')

I want to say, if you can view the Cp then redirect there, else redirect to the frontend. I have this in
app/Http/Responses/LoginResponse.php
app/Http/Responses/LoginResponse.php

class LoginResponse implements LoginResponseContract
{
    public function toResponse($request)
    {
        return auth()->user()->canAccessPanel('TODO') ? 'TODO' : 'TODO';
    }
}
class LoginResponse implements LoginResponseContract
{
    public function toResponse($request)
    {
        return auth()->user()->canAccessPanel('TODO') ? 'TODO' : 'TODO';
    }
}
Solution
Gone with this, which is okay at the moment:
return Auth::user()->canAccessPanel(Filament::getPanel('cp'))
            ? redirect()->intended(route('filament.cp.pages.dashboard'))
            : redirect()->intended(route('home'));
return Auth::user()->canAccessPanel(Filament::getPanel('cp'))
            ? redirect()->intended(route('filament.cp.pages.dashboard'))
            : redirect()->intended(route('home'));
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Redirect to correct panel after login based on account type
FilamentFFilament / ❓┊help
3y ago
redirect panel login to main user panel
FilamentFFilament / ❓┊help
3y ago
How do I customize the redirect after login?
FilamentFFilament / ❓┊help
2y ago
Redirect on a dynamic url after login in a panel
FilamentFFilament / ❓┊help
2y ago