fix
This commit is contained in:
1 parent
4afe60a957
commit
24dbbd7fea
16 files changed
+48
-52
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsPoint;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class MaglooStorePoints
|
||||
{
|
||||
public static function store($data, $base)
|
||||
{
|
||||
ActiveHandicap::set($data);
|
||||
|
||||
foreach ($data as $handicap => $value) {
|
||||
$odds = $value;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
$odds['active_spread'] = $value['active_spread'];
|
||||
$odds['handicap'] = $handicap;
|
||||
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
|
||||
|
||||
$odds = array_merge($odds, $base);
|
||||
|
||||
$res = OddsPoint::where('event_id', $base['event_id'])
|
||||
->where('bookmaker_id', $base['bookmaker_id'])
|
||||
->where('handicap', $odds['handicap'])
|
||||
->first();
|
||||
|
||||
if (! $res) {
|
||||
OddsPoint::create($odds);
|
||||
} else {
|
||||
$res->home = number_format($odds['home'], 2);
|
||||
$res->away = number_format($odds['away'], 2);
|
||||
$res->handicap = number_format($odds['handicap'], 2);
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->checked_at = now();
|
||||
$res->margin = $odds['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user