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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands\Grapper\TxOdds;
|
||||
|
||||
use App\Console\Commands\Grapper\Helper\ActiveSpread;
|
||||
use App\Console\Commands\Grapper\Helper\BookmakerOffer;
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\_2Way;
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\_2WayS1;
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\_3Way;
|
||||
@@ -41,7 +40,6 @@ class Odds
|
||||
Notice::note('txodd odd sport: '.Nuh::$options['sport_id'], 'b');
|
||||
}
|
||||
|
||||
BookmakerOffer::init();
|
||||
/**
|
||||
* Delete
|
||||
*/
|
||||
@@ -269,8 +267,6 @@ class Odds
|
||||
$odds['provider_id'] = Nuh::$options['provider_id'];
|
||||
$odds['nuh_check'] = 0;
|
||||
|
||||
BookmakerOffer::collect($book['bid'], $event['sport_id']);
|
||||
|
||||
foreach ($book->offer as $offer) {
|
||||
|
||||
$bettypeid = 0;
|
||||
@@ -350,8 +346,6 @@ class Odds
|
||||
}
|
||||
}
|
||||
|
||||
BookmakerOffer::finalize();
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('DONE - EVENTS: '.$counter, 'g');
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use App\Models\BookmakerSport;
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\MultilineClient;
|
||||
use App\Models\MultilineSetting;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
@@ -21,6 +21,7 @@ use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
|
||||
class MultilineBookmaker extends Component implements HasActions, HasSchemas, HasTable
|
||||
@@ -56,14 +57,17 @@ class MultilineBookmaker extends Component implements HasActions, HasSchemas, Ha
|
||||
SelectColumn::make('bookmaker_id')
|
||||
->label('Bookmaker')
|
||||
->width('2rem')
|
||||
->options(function () {
|
||||
->options(function ($livewire, $record) {
|
||||
$table = MultilineSetting::where('id', $livewire->tableFilters['multiline_setting_id'])->value('table');
|
||||
|
||||
$res = BookmakerSport::with('bookmaker')
|
||||
$bookies = DB::table($table)
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->get();
|
||||
->groupBy('bookmaker_id')->pluck('bookmaker_id');
|
||||
|
||||
$res = Bookmaker::whereIn('id', $bookies)->pluck('name', 'id');
|
||||
$arr = [];
|
||||
foreach ($res as $value) {
|
||||
$arr[$value->bookmaker_id] = $value->bookmaker->name;
|
||||
foreach ($res as $id => $name) {
|
||||
$arr[$id] = $name;
|
||||
}
|
||||
asort($arr);
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BookmakerSport extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'sport_id',
|
||||
'bookmaker_id',
|
||||
'provider_id',
|
||||
'is_active',
|
||||
];
|
||||
|
||||
public function sport()
|
||||
{
|
||||
return $this->belongsTo(Sport::class);
|
||||
}
|
||||
|
||||
public function bookmaker()
|
||||
{
|
||||
return $this->belongsTo(Bookmaker::class);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user