wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsPoint;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MaglooStorePoints
|
||||
{
|
||||
public static function store($data, $base)
|
||||
{
|
||||
ActiveHandicap::set($data);
|
||||
|
||||
foreach ($data as $handicap => $value) {
|
||||
$odds = $value;
|
||||
$odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1);
|
||||
$odds['active_spread'] = $value['active_spread'];
|
||||
$odds['handicap'] = $handicap;
|
||||
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
|
||||
$odds['flags'] = 1;
|
||||
|
||||
$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->flags = 1;
|
||||
$res->home = number_format($odds['home'], 2);
|
||||
$res->away = number_format($odds['away'], 2);
|
||||
$res->handicap = number_format($odds['handicap'], 2);
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->margin = $odds['margin'];
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user