You can use the following syntax to check ajax request in laravel.
if ($request->ajax()) {
     // Now you can write your code here.
}

BY Best Interview Question ON 06 May 2020