I'd like to access the parameter of a route /search/{type} within my SearchDataTables classes query and html functions so that I can decide which data to use based on the url selected.
Route::resource('search/{type}', 'General\SearchController');
Then something like:
public function query()
{
dd($type);
}
@laf, this is the approach I use when I want to pass a route variable in my dataTable class.
public function search($type, TypeDataTable $dataTable)
{
return $dataTable->forType($type)->render('view.index');
}
protected $type;
public function query()
{
dd($this->type);
}
public function forType($type)
{
$this->type = $type;
return $this;
}
Thanks so much for the quick response. This worked perfectly :)
Thank you also for such an amazing addition to Laravel and DataTables.
Most helpful comment
@laf, this is the approach I use when I want to pass a route variable in my dataTable class.
Controller
DataTable