harishdurga / laravel-quiz

With this package, you can easily get quiz functionality into your Laravel project.
MIT License
162 stars 19 forks source link

Rout key name slug #23

Closed alex1897 closed 2 years ago

alex1897 commented 2 years ago

For the entities with a slug it would be helpful to change the default search from Laravel from id to the slug. Then this search would work:

// routes
Route::get('/quiz/{quiz}', [QuizController::class, 'edit']);

// Quiz model
public function getRouteKeyName()
{
    return 'slug';
}

// controller
public function edit(Quiz $quiz)
{
    dd($quiz);
}