mouadziani/laravel-query-inspector

The missing laravel helper that allows you to ispect your eloquent queries with their binding parameters

1.0.1 2021-07-15 13:49 UTC

This package is not auto-updated.

Last update: 2024-04-13 07:57:15 UTC


README

The missing laravel helper that allows you to ispect your eloquent queries with it's bind parameters

Motivations

Let's say you want to get the generated sql query from an eloquent query, by default in Laravel you can use the toSql() method, but in some situations you may need to get the generated query with its values instead of just getting the prepared statement, in this case you can use this package as well as a helper which will give you the generated sql query with its bind parameters as a plain sql query just by calling toRawSql() from any eloquent query.

Installation

You can install the package via composer:

composer require mouadziani/laravel-query-inspector

Usage

// Using toSql()
$query = Model::where('attribute', 'value')->toSql();
dd($query); // select * from models where attribute = ?

// Using toRawSql()
$query = Model::where('attribute', 'value')->toRawSql();
dd($query); // select * from models where attribute = 'value'

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

featured_repository