39 lines
1015 B
PHP
39 lines
1015 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
|
|
|
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
|
|
use App\Utilities\Margin;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class _PointsQ1
|
|
{
|
|
public static function grap($odds, $offer)
|
|
{
|
|
foreach ($offer as $value) {
|
|
$odds['home'] = (float) $value->o1;
|
|
$odds['away'] = (float) $value->o2;
|
|
$odds['handicap'] = (float) $value->o3;
|
|
}
|
|
|
|
if (fmod((float) $odds['handicap'], 1) != 0.5) {
|
|
return;
|
|
}
|
|
|
|
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
|
|
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
|
|
$odds['updated_at'] = now();
|
|
|
|
DB::table('odds_points_q1')->upsert(
|
|
$odds,
|
|
|
|
['event_id', 'bookmaker_id', 'handicap'],
|
|
|
|
['home', 'away', 'difference', 'margin', 'flags', 'updated_at']
|
|
|
|
);
|
|
|
|
ActiveSpread::collect($odds, 'odds_points_q1');
|
|
}
|
|
}
|