composer install
composer require recca0120/eloquent-dumper
publish config
php artisan vendor:publish --tag="eloquent-dumper"
when you use sqlite in PHPUnit and you need MySQL version sql, you can set driver to mysql, it will output MySQL version sql
// eloquent-dumper.php
return [
/*
* Supported: "pdo", "mysql", "sqlite", "pgsql", "sqlsrv"
*/
'driver' => env('ELOQUENT_DUMPER_GRAMMAR', 'pdo'),
];
var_dump(
User::where('name', 'foo')
->where('password', 'bar')
->sql()
);
User::where('name', 'foo')
->where('password', 'bar')
->dumpSql()
->get();
// output:
// SELECT
// *
// FROM
// `users`
// WHERE
// `name` = 'foo' AND `password` = 'bar'