pascalbaljet
pascalbaljet

Pascal Baljet

Verified

@pascalbaljet

Full-stack Laravel developer and open-source enthusiast. Building software at Protone Media.

16 Posts 1K Views

/ 255

Got most filters working for the React version of Inertia Table. Just need to work on the Date picker, and then it's done 👍

Luckily, I have an E2E test-suite with Laravel Dusk that's not bound to Vue. Quite cool that I can test both versions against the same tests! 🚀

110

In response to @simonhamp

The package supports both MySQL, PostgreSQL, and SQLite, so I needed a quite generic solution. When applying the filter, it checks if the related model uses another connection. If so, it fetches the IDs of the related model first (on the other connection) and adds a constraint to the 'main query' with those IDs. This results in just one extra query, but I think that's totally acceptable in this case as people won't use a ton of filters at once, and it doesn't cause N+1 problems.

2

115

In Laravel, Eloquent does not currently support querying for relationship existence across databases (has(), whereHas(), etc.). Makes sense, as these constraints are applied in a single query.

Fortunately, I have a solution for this in the upcoming Inertia Table release! You can now filter a Model based on a BelongsTo/BelongsToMany/HasOne/HasMany relation, stored in another database than the Model itself 🔥

1

109