'Laravel Implicit Binding Routing with More Than Two Word

We know that Laravel 8 and above has an Implicit Binding function on its routes. I have tried to create a controller resource with model name is QuestionHelper. When I define route with Route resource like below

use App\Http\Controllers\QuestionHelperController;

Route::resource('questionhelper', QuestionHelperController::class);

Unfortunately the implicit binding function doesn't work on the show, edit, update, and delete methods. When I access the show page for example, the data from the implicit binding is empty.

// When I access this method, the $questionHelper variable is empty
public function show(QuestionHelper $questionHelper)
{
    return view('questionhelper.show', compact('questionHelper'));
}

Or shown an error when I access edit method with update method included in edit page.

Illuminate\Routing\Exceptions\UrlGenerationException
Missing required parameter for [Route: questionhelper.update] [URI: admin/questionhelper/{questionhelper}] [Missing parameter: questionhelper]. (View: /var/www/resources/views/questionhelper/edit.blade.php)

Why is this happening? Whereas in other models like Category which only has one word works well.

Thank you.



Solution 1:[1]

    /**
     * $parameter, is $id;
     *
    **/

    <a href="{{ route('questionhelper.update', $parameter)}}"></a>

Solution 2:[2]

I solved it.

If the model name more than 2 words (in this case QuestionHelper) , so basically we need to name our resource name to questionHelper instead of questionhelper

Hm I didn't know that before

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dhamkith
Solution 2 Khoerul Umam