Created
July 8, 2021 02:09
-
-
Save adevesa/26338cf008bef73c7f7d3eeafc80902b to your computer and use it in GitHub Desktop.
AvaliableAppointmentCommand.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Facades\Http; | |
use Illuminate\Support\Str; | |
class AvaliableAppoinmentCommand extends Command | |
{ | |
/** | |
* The name and signature of the console command. | |
* | |
* @var string | |
*/ | |
protected $signature = 'avaliable-appointment'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'A command to know when the there is a appointment avaliable'; | |
/** | |
* Create a new command instance. | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
} | |
/** | |
* Execute the console command. | |
* | |
* @return int | |
*/ | |
public function handle() | |
{ | |
$content = Http::get("https://an-awful-governament-website.com/a-required-procedure")->body(); | |
if(Str::contains($content, 'Actualmente no se encuentran turnos disponibles')){ | |
$this->info('No dates! Try again'); | |
} | |
else{ | |
Http::post("https://maker.ifttt.com/trigger/avaliable-appointment/with/key/a-key-from-ifttt-that-i-cant-share-you"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment