I am new to Laravel and I am trying to make a function to create a database row but my routes are not working.
I currenlty have this in my web.php file:
Route::get('/admin/pagina', [PaginaOverzichtController::class, 'index'])
->name('Admin_Pagina_Overzicht')
->middleware('auth');
Route::post('/admin/pagina', [PaginaOverzichtController::class, 'CreatePage'])
->name('Admin_Pagina_CreatePage')
->middleware('auth');
Route::post('/admin/pagina', [PaginaOverzichtController::class, 'DeletePage'])
->name('Admin_Pagina_DeletePage')
->middleware('auth');
But when I go to /admin/pagina, I get a Route [Admin_Pagina_CreatePage] not defined
error.
Am I allowed to have the same URL but different name pointing to a different function in the same controller? If not, is there a best-practice way to do this?
^
I have a form on my page that should create a page with the method post and action {{ route('Admin_Pagina_CreatePage') }}
My Answer:
Route::post('/admin/pagina', [PaginaOverzichtController::class, 'store']);
Rate this post
3 of 5 based on 5083 votesComments