0

In my app/config/app.php file, I have turned on 'debug'=>true. I have tried

//run eloquent functions
$allMessages = Messages::with('User')->whereIn('conv_id',$conv_id)->orderBy('created_at','aadesc')->take(10);

$q= DB::getQueryLog();
dd($q);

but it returns an empty array. So I guess it is useless to do end($q) as suggested.

I have also tried the accepted answer to a question and added it to the end of my routes file but nothing happened. I'm still new to Laravel and need some guidance. Thank you!

1 Answer 1

2

A popular method is to monitor the Event for Eloquent, and output any queries run on the database as you are going along:

Event::listen('illuminate.query', function($query, $params, $time, $conn) 
{ 
    dd(array($query, $params, $time, $conn));
});

$allMessages = Messages::with('User')->whereIn('conv_id',$conv_id)->orderBy('created_at','aadesc')->take(10);

That will output the query that is run.

Another option is to use a Laravel4 Debugger package, which automatically shows you the queries run: https://github.com/barryvdh/laravel-debugbar

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.