recca0120/eloquent-dumper

v0.2.0 2020-09-03 15:19 UTC

This package is auto-updated.

Last update: 2020-09-03 21:24:47 UTC


README

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'