Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

React Dynamic Data Table Laravel Api Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

  1. composer require langleyfoxall/react-dynamic-data-table-laravel-api
  2. If the package ships a config file, publish it (php artisan vendor:publish --tag=...) and read it end to end before writing any code — export defaults, chunk sizes and similar knobs live there.
  3. Read the vendored README in 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.
  4. First use case: take one existing index page (users, orders, whatever has a real model behind it), define its columns + searchable/sortable/filterable lists, and point a React table at the endpoint. Don't start with relationships or exports — get the flat case rendering first.
  5. On the front end, 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.

Implementation Patterns

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.

Gotchas and Tips

  • Silent no-ops are the default failure mode. A sort or filter on a column not in the allow-list doesn't error — it's just ignored. When "sorting doesn't work", check the allow-list before you check the front end.
  • Front-end/back-end column key drift. The React component sends whatever key you gave the column in JS; the PHP side matches on the DB/alias name. Alias mismatches produce an empty-looking table rather than an exception. Log the resolved column list once during setup.
  • N+1s hide behind pagination. A 25-row page with three relationship columns can fire 75 queries. ->with() in the base query, and check with DB::listen or Telescope before shipping.
  • Search on cast or encrypted columns won't match. 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.
  • Pagination and filter parameter names must match the JS package's defaults. If you've wrapped the endpoint in your own middleware or a proxy that rewrites query strings, parameter names get mangled and you get page 1 forever.
  • Config caching. 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".
  • Exports can blow memory and time limits. Memory exhaustion on a 100k-row CSV is the classic first incident. Queue it, lower the chunk size, and only select the columns the export actually needs.
  • Timezone and number formatting belong in one place. Export formatters and on-screen formatters diverging is a recurring bug report ("the CSV dates are different to the screen"). Share a formatter or accept that you'll fix it twice.
  • 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.
  • Debugging the query. Dump the final builder (->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.
  • Extension points worth knowing: the overridable base-query method (scoping), per-column formatters/renderers (presentation and export), and the published config (export behaviour, batching). Those three cover almost every real-world customisation request; reach for a fork only if the JSON envelope itself needs to change.
  • This release has no breaking changes or deprecations. If you're not on Laravel 13/PHP 8.5, the update is a no-op beyond a version number — no migration work, no API review needed.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log