PHP code example of f-liva / eloquent-to-raw-sql
1. Go to this page and download the library: Download f-liva/eloquent-to-raw-sql library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
f-liva / eloquent-to-raw-sql example snippets
$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` ...