Mihai Stana

Laravel get raw sql query

0 min read ยท 5 July, 2024

useDB;
DB::enableQueryLog();

$posts=Post::where("domain_id",$site->id)
  ->where('published_at','<=',Carbon::now())//UTC+0
  ->where('is_draft',0)
  ->orderBy('published_at','asc')
  ->paginate(10);

$query=DB::getQueryLog();

dd($query);