get acrive bookmaker for multiline direct from table
This commit is contained in:
1 parent
3e06aad008
commit
767164c336
5 files changed
+10
-132
No files matched your search
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Helper;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\BookmakerSport;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class BookmakerOffer
|
||||
{
|
||||
/**
|
||||
* bookmaker overview, what we have from witch povider from what sport
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $collector = [];
|
||||
|
||||
public static function init()
|
||||
{
|
||||
|
||||
if (Nuh::$options['fn'] == 'bkms') {
|
||||
self::$collector = [];
|
||||
}
|
||||
}
|
||||
|
||||
public static function collect($bookmaker_id, $sport_id)
|
||||
{
|
||||
if (Nuh::$options['fn'] == 'bkms') {
|
||||
if (! isset(self::$collector[$sport_id])) {
|
||||
self::$collector[$sport_id] = [];
|
||||
}
|
||||
if (! in_array($bookmaker_id, self::$collector[$sport_id])) {
|
||||
self::$collector[$sport_id][] = (int) $bookmaker_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function finalize()
|
||||
{
|
||||
|
||||
if (Nuh::$options['fn'] == '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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(self::$collector, 'p', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user