Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

obink's avatar
Level 1

Laravel create and passing Id in route

Web Route

route::name('students.')->middleware('auth')->group(function(){
    Route::resource('quiz', 'ResultController');
    Route::get('quiz/create/{id}', [
        'as' => 'quiz',
        'uses' => 'ResultController@createFromHomework'
    ]);


});

Controller

public function createFromHomework($id)
    {
    return 'inside';
    }

View

<a href="{{ route('students.quiz', ['id'=>$homework->id]) }} " class="btn btn-primary">{{$homework->name}} </a>

returning error like

Missing required parameters for [Route: students.quiz] [URI: quiz/create/{id}].

please help.

0 likes
6 replies
obink's avatar
Level 1

I did try to moveroute::resource, or even I try deleting it. it doesn't change my luck.

and for all the records

GET|HEAD  | quiz/create/{id}            | students.quiz                | App\Http\Controllers\ResultController@createFromHomework               | web        | auth       |                                          

the route is already planted in route:list but when I called it in the view, it keeps returning an error.

it's like Laravel trying to tell me that, I need to put the id, but I did put the id

obink's avatar
Level 1
{{dd($homework->id)}}
    {{-- <a href="{{ route('students.quiz', ['id'=>$homework->id]) }}" class="btn btn-primary">{{$homework->name}} </a> --}}

it's a 2, it's number 2, the 2nd row of homework's table

obink's avatar
obink
OP
Best Answer
Level 1

@michaloravec, Michal, SORRY... it was a grave mistake.

the error was saying in my app.blade. it was a route in the navigation I didn't change yet.

so sorry, and ty for your time.. it's all good. it was all my careless. lol

Please or to participate in this conversation.