filter comparatore wip
This commit is contained in:
1 parent
7a9eeb8aad
commit
937c5908d2
40 files changed
+362
-306
No files matched your search
@@ -30,9 +30,13 @@ class Column3way extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
|
||||
$this->has_data = count($record->odds_3ways) ? true : false;
|
||||
|
||||
$this->act = $record->odds_3ways->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
|
||||
@@ -49,12 +53,7 @@ class Column3way extends Column
|
||||
|
||||
$this->min['a3w'] = $record->odds_3ways->min('a3w');
|
||||
|
||||
// $record->odds_3ways = $record->odds_3ways->filter(function (int $value, int $key) {
|
||||
|
||||
// return in_array($this->bookmakers['bookmaker'], $value['bookmaker_id']);
|
||||
|
||||
// });
|
||||
|
||||
$record->odds_3ways = FilterOdds::filter($record->odds_3ways, $this->bookmakers);
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class Column3wayHt extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_3ways_ht) ? true : false;
|
||||
@@ -47,6 +52,8 @@ class Column3wayHt extends Column
|
||||
$this->min['d3w'] = $record->odds_3ways_ht->min('d3w');
|
||||
|
||||
$this->min['a3w'] = $record->odds_3ways_ht->min('a3w');
|
||||
|
||||
$record->odds_3ways_ht = FilterOdds::filter($record->odds_3ways_ht, $this->bookmakers);
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnDc extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_dc) ? true : false;
|
||||
@@ -47,6 +52,8 @@ class ColumnDc extends Column
|
||||
$this->min['dc12'] = $record->odds_dc->min('dc12');
|
||||
|
||||
$this->min['dcx2'] = $record->odds_dc->min('dcx2');
|
||||
|
||||
$record->odds_dc = FilterOdds::filter($record->odds_dc, $this->bookmakers);
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnDnb extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_dnb) ? true : false;
|
||||
@@ -44,6 +49,8 @@ class ColumnDnb extends Column
|
||||
|
||||
$this->min['dnb2'] = $record->odds_dnb->min('dnb2');
|
||||
|
||||
$record->odds_dnb = FilterOdds::filter($record->odds_dnb, $this->bookmakers);
|
||||
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnGgng extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_ggng) ? true : false;
|
||||
@@ -44,6 +49,7 @@ class ColumnGgng extends Column
|
||||
|
||||
$this->min['ng'] = $record->odds_ggng->min('ng');
|
||||
|
||||
$record->odds_ggng = FilterOdds::filter($record->odds_ggng, $this->bookmakers);
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnMl extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_2ways) ? true : false;
|
||||
@@ -44,6 +49,7 @@ class ColumnMl extends Column
|
||||
|
||||
$this->min['a2w'] = $record->odds_2ways->min('a2w');
|
||||
|
||||
$record->odds_2ways = FilterOdds::filter($record->odds_2ways, $this->bookmakers);
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnMlS1 extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_2ways_s1) ? true : false;
|
||||
@@ -44,6 +49,8 @@ class ColumnMlS1 extends Column
|
||||
|
||||
$this->min['a2w'] = $record->odds_2ways->min('a2w');
|
||||
|
||||
$record->odds_2ways_s1 = FilterOdds::filter($record->odds_2ways_s1, $this->bookmakers);
|
||||
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnPoint extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_points) ? true : false;
|
||||
@@ -44,6 +49,8 @@ class ColumnPoint extends Column
|
||||
|
||||
$this->min['away'] = $record->odds_points->min('away');
|
||||
|
||||
$record->odds_points = FilterOdds::filter($record->odds_points, $this->bookmakers);
|
||||
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnPointQ1 extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_points_q1) ? true : false;
|
||||
@@ -44,6 +49,8 @@ class ColumnPointQ1 extends Column
|
||||
|
||||
$this->min['away'] = $record->odds_points_q1->min('away');
|
||||
|
||||
$record->odds_points_q1 = FilterOdds::filter($record->odds_points_q1, $this->bookmakers);
|
||||
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnTotal extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_totals) ? true : false;
|
||||
@@ -44,6 +49,8 @@ class ColumnTotal extends Column
|
||||
|
||||
$this->min['under'] = $record->odds_totals->min('under');
|
||||
|
||||
$record->odds_totals = FilterOdds::filter($record->odds_totals, $this->bookmakers);
|
||||
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnTotalHt extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_totals_ht) ? true : false;
|
||||
@@ -44,6 +49,8 @@ class ColumnTotalHt extends Column
|
||||
|
||||
$this->min['under'] = $record->odds_totals_ht->min('under');
|
||||
|
||||
$record->odds_totals_ht = FilterOdds::filter($record->odds_totals_ht, $this->bookmakers);
|
||||
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnTotalQ1 extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_totals_q1) ? true : false;
|
||||
@@ -44,6 +49,8 @@ class ColumnTotalQ1 extends Column
|
||||
|
||||
$this->min['under'] = $record->odds_totals_q1->min('under');
|
||||
|
||||
$record->odds_totals_q1 = FilterOdds::filter($record->odds_totals_q1, $this->bookmakers);
|
||||
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -30,6 +30,11 @@ class ColumnTq extends Column
|
||||
return $this->bookmakers['bookmaker'] ?? [];
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
{
|
||||
return $this->bookmakers['slots'] ?? [];
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_tq) ? true : false;
|
||||
@@ -44,6 +49,8 @@ class ColumnTq extends Column
|
||||
|
||||
$this->min['atq'] = $record->odds_tq->min('atq');
|
||||
|
||||
$record->odds_tq = FilterOdds::filter($record->odds_tq, $this->bookmakers);
|
||||
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class FilterOdds
|
||||
{
|
||||
public static function filter($data, $bookmakers): Collection
|
||||
{
|
||||
if (auth()->user()->is_multiline_direct) {
|
||||
/**
|
||||
* ORDER
|
||||
*/
|
||||
$order = $bookmakers['bookmaker'] ?? [];
|
||||
|
||||
$data->sortBy(function ($model) use ($order) {
|
||||
return array_search($model->bookmaker_id, $order);
|
||||
});
|
||||
|
||||
/**
|
||||
* FILTER
|
||||
*/
|
||||
if (! auth()->user()->no_filter) {
|
||||
|
||||
$filter = $bookmakers['filter'] ?? [];
|
||||
|
||||
if ($filter) {
|
||||
$data = $data->filter(function ($model) use ($filter) {
|
||||
|
||||
if ($model->bookmaker_id == auth()->user()->bookmaker_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$filter = $filter[$model->bookmaker_id] ?? 0;
|
||||
|
||||
$checked_at = Carbon::createFromDate($model->checked_at)->timestamp;
|
||||
|
||||
if (! isset($filter['margin'])) {
|
||||
dd($model->bookmaker_id);
|
||||
}
|
||||
|
||||
if ($model->margin <= $filter['margin'] && $checked_at > time() - $filter['time_lastcheck']) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tables\Columns\Tools;
|
||||
|
||||
class Compare3way
|
||||
{
|
||||
public static function run($odds_3ways, $bookmakers)
|
||||
{
|
||||
return;
|
||||
$maxrows = 4;
|
||||
$count = 1;
|
||||
$tmp = [];
|
||||
dd($bookmakers);
|
||||
foreach ($bookmakers as $bookmaker) {
|
||||
|
||||
$odds_3ways = $odds_3ways->filter(function ($odds_3ways, $bookmaker) {
|
||||
if ($odds_3ways->contains('bookmaker_id', $bookmaker['bookmaker_id'])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user