Tinkerwell 4 is out now! See what's new or buy now.
Tinkerwell background image
Tinkerwell Logo Tinkerwell
Go back to Blog

Tinkerwell Shorts: Using the new whereExists method in Laravel 10

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');

Laravel 10 makes that a lot easier by simply taking the License model and doing the heavy lifting on it's own:

License::whereColumn('licenses.order_id', 'orders.id');

This looks cleaner and is easier to understand – which is all we care about when we talk about developer UX.

Benjamin Crozat, Indie Hacker & Blogger
“Tinkerwell allows me to prototype ideas in the most efficient way possible. I feel like my life was different before it.”
Benjamin Crozat

Indie Hacker & Blogger

Joel Piccoli da Rosa, Backend developer
“I sincerely don't know how I lived until now without Tinkerwell! I was a really heavy user of "php artisan tinker", but now, with Tinkerwell I can organize my thoughts with ease and with a visual appealing.”

Joel Piccoli da Rosa

Backend developer

Tinkerwell: The PHP Scratchpad

The must-have companion to your favorite IDE. Quickly iterate on PHP code within the context of your web application.

Buy now Learn more