Skip to content

Instantly share code, notes, and snippets.

Vitor Faiante vitorf7

Block or report user

Report or block vitorf7

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
thonyx / binder.php
Last active Sep 3, 2019
Combine binding values into a raw SQL query in Laravel. Debugging in Laravel.
View binder.php
$query = Foo::where('id', '=', 1)->where('name', '=', 'bar');
//would produce the following raw query:
//select * from foo where id = ? and name = ?;
dd(vsprintf(str_replace('?', '%s', $query->toSql()), collect($query->getBindings())->map(function($binding){
return is_numeric($binding) ? $binding : "'{$binding}'";
You can’t perform that action at this time.