comparing wip
This commit is contained in:
1 parent
0cf815c00f
commit
cfee6f6b99
23 files changed
+740
-370
No files matched your search
@@ -11,44 +11,55 @@ class ColumnOdds extends Column
|
||||
|
||||
public $data;
|
||||
|
||||
protected ?array $filter;
|
||||
|
||||
protected ?array $slots;
|
||||
protected $filter;
|
||||
|
||||
protected $bettype;
|
||||
|
||||
public $slots;
|
||||
|
||||
public $bookmaker;
|
||||
|
||||
protected $max;
|
||||
|
||||
protected $min;
|
||||
|
||||
protected $columns;
|
||||
|
||||
protected $client;
|
||||
|
||||
public $compare;
|
||||
|
||||
protected ?array $odds_labels;
|
||||
|
||||
protected ?int $has_data;
|
||||
protected bool $state = true;
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
// $this->setMinMax($record);
|
||||
|
||||
$this->setSlots();
|
||||
|
||||
$this->getData($record);
|
||||
|
||||
if (! $this->data) {
|
||||
$this->has_data = 0;
|
||||
$this->state = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setSlots();
|
||||
|
||||
$this->has_data = count($this->data);
|
||||
|
||||
$order = EventsTable::$slots ?? [];
|
||||
$order = $this->getSlots();
|
||||
$this->data->sortBy(function ($model) use ($order) {
|
||||
return array_search($model->bookmaker_id, $order);
|
||||
});
|
||||
|
||||
$this->setCompare($record);
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/*******************************
|
||||
* PARENT
|
||||
*******************************/
|
||||
public function bettype(string $bettype): static
|
||||
{
|
||||
$this->bettype = $bettype;
|
||||
@@ -56,6 +67,10 @@ class ColumnOdds extends Column
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*******************************
|
||||
* GETTER
|
||||
*******************************/
|
||||
|
||||
public function getBettype()
|
||||
{
|
||||
return $this->bettype;
|
||||
@@ -66,19 +81,18 @@ class ColumnOdds extends Column
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
public function setSlots(): void
|
||||
public function getSlots()
|
||||
{
|
||||
$this->slots = EventsTable::$slots[$this->bettype];
|
||||
if (auth()->user()->is_multiline_direct) {
|
||||
return $this->bookmaker;
|
||||
} else {
|
||||
return $this->slots;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
public function getState(): bool
|
||||
{
|
||||
return $this->slots;
|
||||
}
|
||||
|
||||
public function hasData()
|
||||
{
|
||||
return $this->has_data;
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function getClient()
|
||||
@@ -86,6 +100,11 @@ class ColumnOdds extends Column
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
public function getCompare()
|
||||
{
|
||||
return $this->compare;
|
||||
}
|
||||
|
||||
public function getMax()
|
||||
{
|
||||
return $this->max;
|
||||
@@ -98,6 +117,8 @@ class ColumnOdds extends Column
|
||||
|
||||
public function getData($record)
|
||||
{
|
||||
$this->client = null;
|
||||
$this->data = null;
|
||||
switch ($this->bettype) {
|
||||
case 'odds_2ways':
|
||||
$this->data = $record->odds_2ways;
|
||||
@@ -217,6 +238,10 @@ class ColumnOdds extends Column
|
||||
return $this->odds_labels;
|
||||
}
|
||||
|
||||
/*******************************
|
||||
* SETTER
|
||||
*******************************/
|
||||
|
||||
public function setMinMax($record)
|
||||
{
|
||||
switch ($this->bettype) {
|
||||
@@ -287,4 +312,33 @@ class ColumnOdds extends Column
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setCompare($record)
|
||||
{
|
||||
$this->compare = null;
|
||||
$this->data->filter(function ($model) {
|
||||
|
||||
if ($model->bookmaker_id != auth()->user()->bookmaker_id) {
|
||||
|
||||
$filter = $this->filter[$model->bookmaker_id] ?? 0;
|
||||
|
||||
if ($filter) {
|
||||
if ($model->margin <= $filter['margin']) {
|
||||
$this->compare = $this->data->where('bookmaker_id', $model->bookmaker_id)->first();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function setSlots()
|
||||
{
|
||||
$this->slots = EventsTable::$slots[$this->bettype];
|
||||
|
||||
$this->bookmaker = EventsTable::$bookmaker[$this->bettype];
|
||||
|
||||
$this->filter = EventsTable::$filter[$this->bettype];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user