Tag Archives: SQL from laravel query

How to get raw SQL from laravel query builder

Get raw SQL from laravel query builder

To get the raw SQL query from Laravel’s query builder, you can use the toSql() method. This method returns the raw SQL string that corresponds to the query being built. Here’s an example: Additinay to output last queries ran you can use this: \DB::enableQueryLog(); // Enable query log // Your Eloquent query executed by using …