/** * Execute the console command. * * @return bool * * @dispatches RequestProjectCheckUrl */ public function handle() { $period = []; $minute = intval(date('i')); if ($minute === 0) { $period = [60, 30, 10, 5]; } else { if ($minute % 30 === 0) { $period = [30, 10, 5]; } elseif ($minute % 10 === 0) { $period = [10, 5]; } elseif ($minute % 5 === 0) { $period = [5]; } } if (!empty($period)) { CheckUrlModel::whereIn('period', $period)->chunk(self::URLS_TO_CHECK, function ($urls) { $this->dispatch(new RequestProjectCheckUrl($urls)); }); } return true; }
/** * Execute the console command. * * @return mixed */ public function handle() { $period = []; $minute = intval(date('i')); if ($minute === 0) { $period = [60, 30, 10, 5]; } else { if ($minute % 30 === 0) { $period = [30, 10, 5]; } elseif ($minute % 10 === 0) { $period = [10, 5]; } elseif ($minute % 5 === 0) { $period = [5]; } } if (empty($period)) { return true; } $command = $this; CheckUrlModel::whereIn('period', $period)->chunk(10, function ($urls) use($command) { $command->dispatch(new RequestProjectCheckUrl($urls)); }); }
public function run() { DB::table('check_urls')->delete(); CheckUrl::create(['title' => 'Deployer', 'url' => 'http://deployer.app', 'project_id' => 1, 'period' => 10]); }