Level 73
@shuvoo so I assume you've got Campaign model, right?
Then define your route like this:
Route::get('/leads/{campaign}', 'LeadsController@get_leadsbyid')->name('ManageLeads.get_leadsbyid');
Then in your datatable you can use this for example:
url: '/leads/' + campaign_id,
And in the controller use Route model bidning:
public function get_leadsbyid(Request $request, Campaign $campaign)
{
dd($campaign); // here the campaign should be loaded for that ID.
if (request()->ajax()) {
$leads = datatables()->of(Leads::all())->toJson();
return $leads;
}
return 'Some other response here';
}
Let me know if it works.