Skip to content

recca0120/eloquent-dumper

Repository files navigation

Eloquent Dumper

Install

composer install

composer require recca0120/eloquent-dumper

publish config

php artisan vendor:publish --tag="eloquent-dumper"

Config

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

How to use

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'