Laravel 8 Print Last Query Example

Laravel 8 Print Last Query Example

Hello friends, Today we will show how to print last query in laravel. Sometimes we need to show sql query in laravel. we will learn print last query in laravel 8.  Here you will show laravel 8 get last executed query. We will provide laravel 8 last query, laravel get last query, get last executed query in laravel 8.

Example:

<?php
  
namespace App\Http\Controllers;
  
use App\Models\User;
  
class UserController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function index()
    {
        $query = User::select("*")->toSql();
            
        dd($query);
    }
}

I hope you understand of laravel 8 print last query execute and it can help you…

Read Also :  How to Send Email with Attachment in Laravel 8