langleyfoxall/react-dynamic-data-table-laravel-api
Laravel API backend for Langley Foxall's React Dynamic Data Table. Provides endpoints for server-side pagination, sorting, filtering, and searching, letting React tables query Eloquent models efficiently with minimal setup.
This package is the Laravel half of the react-dynamic-data-table pairing: it turns an Eloquent query into a JSON endpoint that the React component can drive (pagination, sorting, searching, filtering, and exports). v5.6.1 is a pure compatibility patch — it widens the helpers-laravel constraint to allow v4 so the package installs cleanly on PHP 8.5 / Laravel 13 — so there is nothing new to learn here, but it is a good moment to get a first table running.
composer require langleyfoxall/react-dynamic-data-table-laravel-apiphp artisan vendor:publish --tag=...) and read it end to end before writing any code — export defaults, chunk sizes and similar knobs live there.vendor/langleyfoxall/react-dynamic-data-table-laravel-api alongside the npm package's docs. The contract between the two is the JSON shape, and that is where 90% of your debugging time will go.npm i react-dynamic-data-table and pass your endpoint URL plus the matching column keys.The first thing to look at in the source is the base class/controller the package exposes — everything you'll want to customise (base query, column resolution, response shaping) is a method on it.
One definition class per resource. Rather than an inline closure in routes/web.php, create a dedicated controller or definition class per table. You will end up overriding base-query and column logic for tenancy, soft deletes, or role-based column visibility, and that's much cleaner in a class.
Declare columns once, reuse everywhere. The column list should be the single source of truth for the on-screen table and the export. Where possible, derive the export definition from the same array so a column added to the UI doesn't silently go missing from the CSV.
Treat searchable/sortable/filterable as allow-lists, not configuration sugar. They're your protection against ?sort=password_hash and against ORDER BY on arbitrary input. Keep them explicit and keep them in sync with what the React side advertises as sortable.
Relationships: eager-load, don't join by default. For a column backed by user.team.name, override the base query with ->with('team') (or use withCount/withSum for aggregate columns) and render via an accessor. Raw joins are faster but collide with column naming and break paginate() counts when the relation is one-to-many.
Computed columns via accessors, not selectRaw. Adding an Attribute/accessor (getFullNameAttribute) keeps the SQL portable and keeps sorting working if you also register the underlying columns. selectRaw columns can be displayed but usually can't be sorted or searched without extra work.
Scope in the base query. Tenant isolation, where('archived', false), and permission filters all belong in the overridden query method, not in a middleware — that way the export path inherits the exact same scoping as the on-screen table. Test both paths.
Exports for large sets. Small tables are fine synchronously; once you're past a few thousand rows, push the export onto a queue and email/notify the download link. The package's chunked export is the pattern to follow, and the config file's batch size is the knob that matters.
Feature-test the endpoint, not the class. A short test hitting the route and asserting the JSON envelope (data, total/per-page/page keys, and that an unknown sort column is ignored) will catch 95% of regressions, including the kind of dependency shuffle this release introduces.
Upgrading to 5.6.1. A composer update langleyfoxall/react-dynamic-data-table-laravel-api will now be allowed to pull helpers-laravel v4 alongside it. On Laravel 13/PHP 8.5 that's exactly what you want; on older stacks Composer will simply keep the v3 line. Run your table feature tests after the bump — the helper package is a transitive dependency that other Langley Foxall packages may also constrain.
->with() in the base query, and check with DB::listen or Telescope before shipping.LIKE against a JSON cast, an encrypted attribute, or a datetime formatted by an accessor returns nothing useful. Restrict searchable to genuine text columns, or implement a custom search that hits the underlying raw column.php artisan config:cache in deploy will quietly freeze export settings; remember to re-run it after changing the published config, and to clear it locally when a config edit "doesn't take".helpers-laravel constraint conflicts. If another Langley Foxall package pins helpers-laravel to ^3, the 5.6.1 bump can surface as an unsolvable dependency set. composer why langleyfoxall/helpers-laravel tells you who's holding it back.->toSql() plus bindings) from inside your definition class — the package builds on top of your query, so a mistake there is invisible in the response payload.How can I help you explore Laravel packages today?