recca0120/eloquent-dumper

v0.7.0 2024-03-12 21:00 UTC

This package is auto-updated.

Last update: 2024-11-12 22:27:29 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'