f-liva / eloquent-to-raw-sql
Exposes the eloquent toRawSql method to display the raw query in beautified form.
1.0.2
2024-11-22 09:35 UTC
Requires
README
Exposes the eloquent toRawSql method to display the raw query in beautified form.
Install
composer require f-liva/eloquent-to-raw-sql
Use
$products = Product ::where('availability', 'available') ->where('type', 'goods') ->groupBy('category') ->orderByDesc('price') ->limit(10); dump($products->toRawSql()); // Beautified SQL (as default) // SELECT // * // FROM // `products` // WHERE // `products`.`availability` = 'available' // AND `products`.`type` = 'goods' // GROUP BY // `products`.`category` // ORDER BY // `products`.`price` DESC // LIMIT 10; dump($products->toRawSql(false)); // Unbeautified SQL // SELECT * FROM `products` WHERE `products`.`availability` ...