PyaeSoneAungRgn
/
to-raw-sql
Get raw SQL from Laravel Query Builder and Eloquent Builder
To Raw SQL
toRawSql()
function is included by default in Laravel 10.15.0. You don't need to install this package if your Laravel version is greater than 10.14.1
Get raw SQL from Laravel Query Builder and Eloquent Builder
Installation
composer require pyaesoneaung/to-raw-sql
Usage
User::where('votes', '>', 100)
->orWhere(function ($query) {
$query->where('name', 'Abigail')
->where('votes', '>', 50);
})
->toRawSql();
// "select * from `users` where `votes` > 100 or (`name` = 'Abigail' and `votes` > 50)"
DB::table('users')
->whereBetween('votes', [1, 100])
->toRawSql();
// "select * from `users` where `votes` between 1 and 100"
Version History
…You can get raw SQL from Laravel Query Builder using PyaeSoneAungRgn/to-raw-sql
Top comments (0)