elargento23
2 weeks ago
168
12
Laravel

Passing a parameter through URL

Posted 2 weeks ago by elargento23

Route::get('/questions/{category}', '[email protected]')->name('welcomesecond');

executes the following:

public function second($degree_id) {
    $question = DB::table('questions')
        ->select('questions.question_text','questions.answer_time_minutes','questions.answer_time_seconds')
        ->join('universities', 'universities.university_id', 'questions.university_id')
        ->orderByRaw('RAND()')
        ->where('questions.degree_id', $degree_id)
        ->take(1)->first();

    return view('2ndscreen', compact('question'));
}

However, even when I pass the value through the URL, $degree_id has no value assigned: URL: questions/1

Any ideas what I am doing wrong?

Please sign in or create an account to participate in this conversation.