I'm using server-side DataTables in Laravel (Yajra to be specific).
I have a route set up that pulls all assets and returns as a DataTable, but what I need is to pull all assets where the school_id is equal to the parameter in the URL.
So my application should look like this:
- User lands on /schools/{school_id}/assets .e.g schools/1/assets
- Datatables pulls all school's assets using that {school_id}
I'm using the following so far in the script:
$(function() {
$('#assets-table').DataTable({
processing: true,
serverSide: true,
ajax: '/api/assets',
columns: [
{data: 'asset_tag', name: 'assets.asset_tag'},
{data: 'name', name: 'assets.name'},
]
});
});
What would be the best approach to fetching that ID in the URL and passing it to that ajax request?