longkoy732
Route [filament.pages.dashboard] not defined.
What I am trying to do:
What I'm trying to do is to apply the RedirectIfAuthenticatedWithRole middleware to the /dashboard in my web.php as you can see i am using a function because i don't have a controller for dashboard because i am using filament. Seeing in my route list the filament.pages.dashboard is not registered.
here is the route list for the dashboard:
GET|HEAD dashboard ........................................................................................................................................................
here is the route /dashboard in my web.php:
Route::get('/dashboard', function () {})->middleware('role.redirect');
here is the custom RedirectIfAuthenticatedWithRole:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
class RedirectIfAuthenticatedWithRole
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
$user = Auth::user();
if ($user->roles->contains('name', 'super-admin')) {
return Redirect::to('/dashboard');
} elseif ($user->roles->contains('name', 'Agent') || $user->roles->contains('name', 'agent')) {
return Redirect::to('/dashboard/send-email');
} else {
return Redirect::to(Config::get('google-sso.auth_redirect'));
}
return $next($request);
}
}
What I did:
I put return view(filament.pages.dashboard); still i got the same error.
My issue/the error:
That's why in my web.php when i redirect to dashboard i get error Route [filament.pages.dashboard] not defined.
2 replies