sentry-laravel
sentry-laravel copied to clipboard
Improve the display of sql.binding in breadcrumbs
I often use Value Objects as values in Eloquent queries, these classes look something like this:
<?php
declare(strict_types=1);
namespace App\ValueObjects;
use InvalidArgumentException;
final class UserName
{
public function __construct(private string $value)
{
if (empty($value)) {
throw new InvalidArgumentException('Name cannot be empty.');
}
}
public function getValue(): string
{
return $this->value;
}
public function __toString(): string
{
return $this->value;
}
}
The logic of the execution itself looks like this:
Route::get('/debug-sentry', function () {
\Illuminate\Support\Facades\DB::transaction(static function () {
\App\Models\User::query()
->create([
'name' => new \App\ValueObjects\UserName('My Name'),
'email' => new \App\ValueObjects\UserEmail('[email protected]'),
'password' => new \App\ValueObjects\UserPassword('password'),
]);
throw new Exception('Just error');
});
});
And when any error occurs, in BREADCRUMBS, in the sql.query category I see the following:

All passed objects turn into {}, it would be cool if I could see the actual values that eloquent performs.