/** * A function to update a faucet's status (active or paused) * according to their low-balance status and if the * faucet's URL is error-free and valid. */ public static function checkUpdateStatuses() { //Retrieve faucets to be updated. $faucets = Faucet::all(); $pausedFaucets = []; $activatedFaucets = []; foreach ($faucets as $f) { if (UrlValidation::urlExists($f->url) != true && $f->is_paused == false && $f->has_low_balance == false) { $f->is_paused = true; $f->save(); array_push($pausedFaucets, $f->name); } elseif (UrlValidation::urlExists($f->url) != false && $f->is_paused == true && $f->has_low_balance == false) { $f->is_paused = false; $f->save(); array_push($activatedFaucets, $f->name); } } if (count($pausedFaucets) == 0 && count($activatedFaucets) == 0) { Session::flash('success_message_update_faucet_statuses_none', 'No faucets have been updated.'); } if (count($pausedFaucets) > 0) { Session::flash('success_message_update_faucet_statuses_paused', 'The following faucets have been paused: ' . implode(",", $pausedFaucets)); } if (count($activatedFaucets) > 0) { Session::flash('success_message_update_faucet_statuses_activated', 'The following faucets have been activated: ' . implode(",", $activatedFaucets)); } }
/** * WebsiteMeta constructor. * @param $url * @throws Exception */ public function __construct($url) { if (UrlValidation::urlExists($url) == true) { $this->url = $url; } else { throw new Exception('The URL does not exist or is experiencing technical issues.'); } }