samedi 9 février 2019

Scheduler not running Laravel 5

I'm trying to run a scheduler that grabs bitcoin prices every minute and add them to a database, but I can't get the larval scheduler to run properly.

I've tested the sql code in a separate php page and it works but the scheduler doesn't seem to be running

Schedule function is in kernel.php Handle function is in Jobs/UpdateRates

protected function schedule(Schedule $schedule)
{
    $schedule->job(new \App\Jobs\UpdateRates)->everyMinute();

}


public function handle()
{
    $url = "https://bitpay.com/api/rates";
    $json = file_get_contents($url);
    $data = json_decode($json, TRUE);
    $rate = $data[1]["rate"];    
    $usd_price = 10;     # Let cost of elephant be 10$
    $bitcoin_price = round( $usd_price / $rate , 8 );

    DB::insert('insert into settings (bitcoin_rate, monero_rate) values (?, ?)', [0, 1]);
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire