Print Laravel Query Or Debug Laravel Query
Method 1:-
$posts = Post::where('id',' '> ,10)->toSql();
dd($posts);
Method 2:-
DB::enabLeQueryLog(); // Enable query tog
$posts = Post::with('comments')->where('id',' '> ,10)->get();
dd(DB::getQueryLog()); // Show results of tog
Method 3:-
$posts = Post::with('comments')->where('id',' '> ,10)->get();
$comments = Comments::all();
DB::listen (function($query) {
print_r(value: "DB:" . $query->sql ."[".implode(separator. " , " , $query->bindings) . "]");
});
Comments
Post a Comment