Forked from tomcastleman/DumpSqlServiceProvider.php
Created
September 13, 2017 16:25
-
-
Save stevepop/efc369b68e025a267995acbe07b06aff to your computer and use it in GitHub Desktop.
Laravel Query Builder Dump SQL Macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Database\Query\Builder; | |
use Illuminate\Support\ServiceProvider; | |
class DumpSqlServiceProvider extends ServiceProvider | |
{ | |
public function boot() | |
{ | |
} | |
public function register() | |
{ | |
Builder::macro('dumpSql', function ($die = false) { | |
/** Builder $this */ | |
dump($this->toSql()); | |
$method = $die ? 'dd' : 'dump'; | |
$method($this->getBindings()); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment