stuck with livewire

This commit is contained in:
salam committed 2026-01-11 09:09:16 +01:00
1 parent b21cdb507a
commit c0f2689ff6
30 files changed
+372 -64

No files matched your search

@@ -0,0 +1,53 @@
<?php
namespace App\Console\Commands\Grapper\Helper;
use App\Console\Commands\Nuh;
use Illuminate\Support\Facades\DB;
class ActiveSpread
{
public static function collect($odds, $bettype)
{
if (! isset(Nuh::$collector[$bettype][Nuh::$bookmaker_id]['difference'])) {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['difference'] = $odds['difference'];
if (isset($odds['handicap'])) {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['active_spread'] = $odds['handicap'];
} else {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['active_spread'] = $odds['total'];
}
} elseif ($odds['difference'] < Nuh::$collector[$bettype][Nuh::$bookmaker_id]['difference']) {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['difference'] = $odds['difference'];
if (isset($odds['handicap'])) {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['active_spread'] = $odds['handicap'];
} else {
Nuh::$collector[$bettype][Nuh::$bookmaker_id]['active_spread'] = $odds['total'];
}
}
}
public static function set()
{
foreach (Nuh::$collector as $table => $value) {
DB::table($table)->where('event_id', Nuh::$id)->where('provider_id', Nuh::$options['provider_id'])->update(['active_spread' => 0]);
}
foreach (Nuh::$collector as $table => $bookmaker) {
foreach ($bookmaker as $bookmaker_id => $values) {
if (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
DB::table($table)
->where('event_id', Nuh::$id)
->where('bookmaker_id', $bookmaker_id)
->where('handicap', $values['active_spread'])
->update(['active_spread' => 1]);
} else {
DB::table($table)
->where('event_id', Nuh::$id)
->where('bookmaker_id', $bookmaker_id)
->where('total', $values['active_spread'])
->update(['active_spread' => 1]);
}
}
}
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Console\Commands\Grapper\Helper;
use App\Console\Commands\Nuh;
use App\Models\BookmakerSport;
class BookmakerOffer
{
/**
* bookmaker overview, what we have from witch povider from what sport
*
* @var array
*/
public static $collector = [];
public static function init()
{
$debug = Nuh::$options['d'] ?? 0;
if (Nuh::$options['d'] == 'bkms') {
self::$collector = [];
}
}
public static function collect($bookmaker_id, $sport_id)
{
if (Nuh::$options['d'] == 'bkms') {
if (! isset(self::$collector[$sport_id])) {
self::$collector[$sport_id] = [];
}
if (! in_array($bookmaker_id, self::$collector[$sport_id])) {
self::$collector[$sport_id][] = $bookmaker_id;
}
}
}
public static function finalize()
{
if (Nuh::$options['d'] == 'bkms') {
foreach (self::$collector as $sport_id => $bookmaker_ids) {
BookmakerSport::where('provider_id', Nuh::$options['provider_id'])
->where('sport_id', (int) $sport_id)
->update(['is_active' => 0]);
foreach ($bookmaker_ids as $bookmaker_id) {
BookmakerSport::updateOrCreate([
'provider_id' => Nuh::$options['provider_id'],
'bookmaker_id' => (int) $bookmaker_id,
'sport_id' => (int) $sport_id,
], [
'is_active' => 1,
]);
}
}
}
}
}