第一种:

App\User::query()
    ->where('created_at', '<', now()->subYear())
    ->with('assignedApps', 'courses')
    ->orderBy('email', 'asc')
    ->limit(5)
    ->toSql();
    
//
$product = Product::where('id',77)->toSql();
echo $product;

 

第二种:

DB::enableQueryLog();
 
App\User::query()
    ->where('created_at', '<', now()->subYear())
    ->with('assignedApps', 'courses')
    ->orderBy('email', 'asc')
    ->limit(5)
    ->get();
 
echo DB::getQueryLog();

 

© 本文著作权归作者所有。转载请联系授权,禁止商用。