I've managed to correctly set up a Laravel DataTable with the following code in a controller method:
// Retrieve (potentially filtered) data
$users = User::with("role", "language", "country") -> select(["support_code", "first_name", "last_name", "subscription_expires", "email_address", "user_name", "location", "role_id", "language_id", "country_id"]);
// Return data as JSON
return Datatables::of($users) -> make(true);
However, I now wish to move this code out of the controller and into a domain object / separate class.
The problem is that this doesn't work as the DataTables JS sends a long query string via its ajax method and this isn't being passed along to the domain class.
So... two questions. First, how do I send this query string to the domain class. Second, how do I offer it up to the Datatables::of($users) -> make(true)
method?
Many thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire