File: /var/www/vhost/disk-apps/qas.sports-crowd.com/app/Console/Commands/LiveScoreTeamCommand.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Http\Controllers\LiveScoreApiController;
use App\MatchEvent;
use App\Parameter;
class LiveScoreTeamCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sportscrowd:livescore';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Obtiene los eventos del partido en vivo configurado en parametros';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$parameters = Parameter::select('live_score_active')->first();
if (!$parameters || !$parameters->live_score_active) {
return 0;
}
// Eliminar caches finalizadas
$m = MatchEvent::where("active", true)->first();
if ($m) {
$c = new LiveScoreApiController;
$c->getLiveScore();
return 0;
} else {
$out = new \Symfony\Component\Console\Output\ConsoleOutput();
$out->writeln("No hay partidos actualmente");
}
}
}