namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class AjaxOnly
{
public function handle($request, Closure $next)
{
if(!$request->ajax()){
throw new BadRequestHttpException('This resource only accepts an ajax requests');
}
return $next($request);
}
}