public function getEventAdd($chapterid)
{
if($chapterid)
{
$chapterdetail = Chapter::where('id',$chapterid)->first();
return view('adminfiles.events.addevent',compact('chapterdetail'));
} else {
return redirect('admindashboard')->withErrors('Select any one chapter');
}
}
if you can see here i am checking chapterid exists or not in every controller function so i am planning to create new middleware to check this route parameter exists or not.