I have resource route like this
Route::resource('chapter', 'ChapterController');
I want to pass parameter id to it like this
Route::resource('chapter/{id}', 'ChapterController');
and use it in my controller like this
public function index($id)
{
$subject=Subject::find($id);
$chapter=Chapter::where('subject_id',$id)->get();
return view('chapter.index',[
'subject'=>$subject,
'chapter'=>$chapter
]);
}
Please help me