How to debug eloquent query
How to debug eloquent query.
There is way to dump query for example mysql with prepared variables next way:
// Enable query log
\DB::connection('mysql')->enableQueryLog();
// Execute query
$res = SomeModel::where('field', '=', $field)->latest('created_at', 'desc')->
select(['created_at', 'value'])->
limit(10)->
get();
// Get last query from log
$query = \DB::getQueryLog();
$lastQuery = end($query);
echo 'lastQuery: ';
var_dump($lastQuery);
