In my Laravel app and as a scheduled task, I want to make an Http request in my custom class but I get
Class 'Illuminate\Support\Facades\Http' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'Illuminate\\Support\\Facades\\Http' not found
Here is my custom class
<?php
namespace App\MyModels\GetData;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class Test
{
public function __invoke()
{
Log::info("Cron executed : ");
$response = Http::get("https://google.com");
Log::info(print_r($response, true));
}
}
in Laravel documentation, it says :
To make requests, you may use the get, post, put, patch, and delete methods. First, let's examine how to make a basic GET request:
use Illuminate\Support\Facades\Http;
$response = Http::get('http://test.com');