Laravel 10 makes writing whereExists
queries in Laravel applications much easier. Previously, it the whereExists
relation required a custom query within a closure but luckily, Laravel 10 solves this in a better way with a much higher developer UX.
In our licensing platform at beyondco.de, we manage licenses of multiple products. If we want to list all orders that include a Tinkerwell license, we would need to write an Eloquent like this:
Order::whereExists(function ($query) { $query->from('licenses')->whereColumn('licenses.order_id', 'orders.id');})->count();)->count();
Laravel 10 makes that a lot easier by simply taking the License
model and doing the heavy lifting on it's own:
Order::whereExists( License::whereColumn('licenses.order_id', 'orders.id');)->count();
This looks cleaner and is easier to understand – which is all we care about when we talk about developer UX.
“The ability to SSH directly into a server and run diagnostics directly from Tinkerwell is insanely amazing! Can't imagine doing development without it at this point.”Jake Bennett
Director of Technology and Innovation
“A big fan of BeyondCode's work, Tinkerwell is a game changer for a freelancer like me, it saves me a lot of time. It was without any hesitation that I opted for the lifetime license.”Dominique Thomas
Laravel Developer / CEO of NCOO DEV
The must-have companion to your favorite IDE. Quickly iterate on PHP code within the context of your web application.
Buy now Learn more