Here’s the small code snippet needed to quickly log the SQL output for your last executed Eloqent query in Laravel 5. I’ve had to look this up so many times, that I decided to just post it here for my own convenience. If you forget to enable the query log, you’ll notice that it will be empty all the time.
$query = \DB::getQueryLog();
$lastQuery = end($query);
About the author
Hi there! I'm a freelancer who can help you build a great application or website - yes, also for mobile devices. If you speak Dutch, check out my eBooks.
Hire me, whether it's to help you build your next project or to organize a workshop. I teach about web design + development in college and I'd be happy to put a workshop together for you.