-3

I'm new to laravel..

and i got an error

Route [student] not defined.

this is the code in my view `

<a href="{{ route('student', $student->id) }}" class="font-medium text-blue-600 dark:text-blue-500 hover:underline hover:text-blue-800 dark:hover:text-blue-400">
detail
</a>

` this is the code in my controller

Route::get('/student/{id}', [
    'as' => 'student',
    StudentController::class,
    'ShowDetail',
]);

how do i fix it?

sorry my english is not very good, i don't know how to explain it but I want when "detail" is clicked it will move page to student/id or ( student/123 ) with id , then on the next page, it will display student data based on the id that was brought earlier

Ray Zhm
  • 1
  • 2
  • 3
    `'as' => 'student'` is the old syntax for naming routes. In more recent versions, you use `Route::get('/student/{id}', [StudentController::class, 'showDetail'])->name('student');` Please read the documentation: https://laravel.com/docs/9.x/routing#named-routes – Tim Lewis Dec 14 '22 at 16:11

1 Answers1

1

Try using

Route::get('/student/{id}', [StudentController::class, 'ShowDetail'])->name('student');

And calling the route with

<a href="{{ route('student', ['id' => $student->id]) }}"