phplaravellaravel-backpack

How to load custom data to backpack-for-laravel datatable list?


I'm new to Backpack for Laravel, it's been great so far. Now I would like to display a list of custom data with the same presentation as a CRUD list.

These data would be the result of a custom SQL query, and the results are few lines but aren't related to a particular model, and some actions on the last column, exactly as a CRUD list, but I would populate the datatable with an array or an Illuminate\Database\Query\Builder for instance?


Solution

  • Just overwrite the search() method in the Controllers you use the ListOperation (that includes the table).

    As long as you return the data in the same format we do, the table should be able to render just fine.

    Alternatively, a more "clean" way to do it would be to use the https://github.com/calebporzio/sushi package to "simulate" a model from an array, list of files, custom queries whatever you feel like.

    Cheers