Laravel 11 Target class does not exist.

Hi guys I just wanna ask what are the solution I can try to fix this error? When Im clicing on my log out href on my dashboard, it also direct me to the url of localhost:8000/establishment/logout instead of localhost:8000/establishment/login and give me the error of Target class [establishment] does not exist. All my middleware, controller, route, auth.php are correct I tried GPT still cant solved the problem. Tech Laravel 11 Breeze, React Important Codes Snippet below Dashboard.jsx
<a href={route('establishment.logout')}
method="get"
as="button">
Log out
</a>
<a href={route('establishment.logout')}
method="get"
as="button">
Log out
</a>
web.php
Route::prefix('establishment')->group(function() {
Route::get('/login', [EstablishmentController::class, 'EstablishmentIndex'])->name('establishment.login');
Route::post('/login/user', [EstablishmentController::class, 'EstablishmentLogin'])->name('establishment.login.user');
Route::get('logout', [EstablishmentController::class, 'EstablishmentLogout'])->name('establishment.logout')->middleware('establishment');

});
Route::prefix('establishment')->group(function() {
Route::get('/login', [EstablishmentController::class, 'EstablishmentIndex'])->name('establishment.login');
Route::post('/login/user', [EstablishmentController::class, 'EstablishmentLogin'])->name('establishment.login.user');
Route::get('logout', [EstablishmentController::class, 'EstablishmentLogout'])->name('establishment.logout')->middleware('establishment');

});
Establishment.php
public function EstablishmentLogout(){
Auth::guard('establishment')->logout();
return redirect()->route('establishment.login')->with('loggedout', 'Logged out successfully');
}
public function EstablishmentLogout(){
Auth::guard('establishment')->logout();
return redirect()->route('establishment.login')->with('loggedout', 'Logged out successfully');
}
EstablishmentMiddleware
public function handle(Request $request, Closure $next): Response
{
if (!Auth::guard('establishment')->check()){
return redirect()->route('establishment.login')->with('Error','Please login first');
}

return $next($request);


}
public function handle(Request $request, Closure $next): Response
{
if (!Auth::guard('establishment')->check()){
return redirect()->route('establishment.login')->with('Error','Please login first');
}

return $next($request);


}
No description
11 Replies
ἔρως
ἔρως2mo ago
whats the namespace of that ::class you used there?
sebin
sebinOP2mo ago
No description
ἔρως
ἔρως2mo ago
and did you use the class in your web.php file?
sebin
sebinOP2mo ago
Yes I imported it. I also used the other syntax of importing it on route which is App\Http\Controllers\EstablishmentController::class, use App\Http\Controllers\EstablishmentController; same problem.
sebin
sebinOP2mo ago
Tho removing the middleware fix the problem, but being auth is what I want.
No description
sebin
sebinOP2mo ago
the middleware
No description
sebin
sebinOP2mo ago
Its working now. Thank god.
No description
sebin
sebinOP2mo ago
I dont know what happen but my admin route have a same syntax and I did not even import the AdmidMIddleware, but hey at least my admin is working hahaha
No description
ἔρως
ἔρως2mo ago
i honestly cant say exactly whats wrong, but the important is that it works
Jochem
Jochem2mo ago
Laravel in a nutshell
ἔρως
ἔρως2mo ago
🤣 that was how i felt with lumen
Want results from more Discord servers?
Add your server