Custom function in Laravel cannot find route in resource controller
P粉904450959
P粉904450959 2023-09-10 11:32:46
0
1
535

I have a checkIn function in LoginController:

The path of

LoginController.php is: Controllers/Backsite/LoginController

public function checkIn(Request $request, User $user)
{ 
   ...
}

I have defined them in web.php:

Route::group(['prefix' => 'backsite', 'as' => 'backsite.', 'middleware' => ['auth:sanctum', 'verified']], function(){
   Route::get('/login/checkIn', [LoginController::class, 'checkIn']);
});

I call them by using the following code in blade.php:

<button type="button" class="btn btn-primary btn-min-width mr-1 mb-1" href={{ route('backsite.login.checkIn') }}>CheckIn</button>
<button type="button" class="btn btn-info btn-min-width mr-1 mb-1" href={{ route('backsite.login.checkOut') }}>CheckOut</button>

But it shows an error of Route [backsite.login.checkIn] not defined.

I'm using Laravel 8 and have tried other methods found on Stackoverflow but still getting the error.

P粉904450959
P粉904450959

reply all(1)
P粉693126115

"Undefined route error" occurs when you try to use an undefined route, please update your code and define the route in the path.

Route::group(['prefix' => 'backsite', 'as' => 'backsite.', 'middleware' => ['auth:sanctum', 'verified']], function(){
   Route::get('/login/checkIn', [LoginController::class, 'checkIn'])->name('login.checkIn');
});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template