diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php
index fb7b5482..c9fd6cc3 100644
--- a/app/Filament/Pages/Statistic.php
+++ b/app/Filament/Pages/Statistic.php
@@ -129,7 +129,7 @@ class Statistic extends BaseDashboard
Grid::make([
'default' => 1,
- 'sm' => 3,
+ 'sm' => 2,
'md' => 5,
])
->columnSpanFull()
@@ -139,10 +139,10 @@ class Statistic extends BaseDashboard
->live()
->preload()
->searchable(false)
- ->prefixIconColor(fn (Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger')
+ ->prefixIconColor(fn(Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger')
->prefixIcon('phosphor-globe-fill')
->hiddenLabel()
- ->options(fn () => LoadSofaScoreCategory::load())
+ ->options(fn() => LoadSofaScoreCategory::load())
->placeholder('Select Country')
->afterStateUpdated(function (callable $set, $state) {
$set('seasonmode', SofaScoreCategory::where('id', $state)->value('season_mode'));
@@ -155,10 +155,10 @@ class Statistic extends BaseDashboard
Select::make('league_id')
->live()
->preload()
- ->prefixIconColor(fn (Get $get): string => $get('league_id') ? 'success' : 'danger')
+ ->prefixIconColor(fn(Get $get): string => $get('league_id') ? 'success' : 'danger')
->prefixIcon('phosphor-trophy-fill')
->hiddenLabel()
- ->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id')))
+ ->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id')))
->placeholder('Select League')
->afterStateUpdated(function (callable $set) {
$set('match_id', null);
@@ -169,8 +169,8 @@ class Statistic extends BaseDashboard
Select::make('match_id')
->live()
->hiddenLabel()
- ->columnSpan(fn (Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1)
- ->prefixIconColor(fn (Get $get): string => $get('match_id') ? 'success' : 'danger')
+ ->columnSpan(fn(Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1)
+ ->prefixIconColor(fn(Get $get): string => $get('match_id') ? 'success' : 'danger')
->prefixIcon('phosphor-calendar-check-fill')
->options(function (Get $get) {
return LoadStatisticFixturesMatchOptions::load($get('league_id'));
@@ -183,10 +183,10 @@ class Statistic extends BaseDashboard
->placeholder('Select Event'),
Action::make('esc')
->hiddenLabel()
- ->visible(fn (Get $get) => $get('similar_past_matches') != 'none')
- ->tooltip('Clear all (esc)')
+ ->visible(fn(Get $get) => $get('similar_past_matches') != 'none')
+ ->tooltip('Clear All (esc)')
->icon('phosphor-x-circle')
- ->color('warning')
+ ->color('danger')
->keyBindings(['esc'])
->action('resetFilters'),
@@ -202,8 +202,13 @@ class Statistic extends BaseDashboard
return 'danger';
}
})
- ->prefixIcon('phosphor-users-three-fill')
- ->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
+ ->prefixIcon('phosphor-users-fill')
+ ->suffixAction(Action::make('reset')
+ ->icon('phosphor-x-circle')
+ ->tooltip('Clear Team')
+ ->action(fn(callable $set) => $set('team_id', null))
+ ->color(fn(Get $get): string => $get('team_id') != 0 ? 'danger' : 'gray'))
+ ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->options(function (Get $get) {
if ($get('match_id')) {
$res = StatisticFixtures::where('id', $get('match_id'))->first();
@@ -222,7 +227,14 @@ class Statistic extends BaseDashboard
$this->dispatch('reset-tab');
})
->placeholder('Select Team'),
-
+ ]),
+ Grid::make([
+ 'default' => 1,
+ 'sm' => 3,
+ 'md' => 5,
+ ])
+ ->columnSpanFull()
+ ->schema([
Select::make('team_position')
->live()
->hiddenLabel()
@@ -232,9 +244,9 @@ class Statistic extends BaseDashboard
Action::make('iconInfo')
->color('success')
->icon('phosphor-question-fill')
- ->tooltip(fn () => 'Team Position')
+ ->tooltip(fn() => 'Team Position')
)
- ->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
+ ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->default('all')
->selectablePlaceholder(false)
->options([
@@ -244,14 +256,6 @@ class Statistic extends BaseDashboard
])->afterStateUpdated(function (callable $set) {
$set('ss_player_id', null);
}),
- ]),
- Grid::make([
- 'default' => 1,
- 'sm' => 3,
- 'md' => 5,
- ])
- ->columnSpanFull()
- ->schema([
Select::make('statistic_type')
->live()
->hiddenLabel()
@@ -289,20 +293,21 @@ class Statistic extends BaseDashboard
->live()
// ->columnSpan(2)
->hiddenLabel()
- ->columnSpan(fn (Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1)
+ ->hidden(fn(Get $get) => $get('team_id') != null)
+ ->columnSpan(fn(Get $get) => $get('similar_past_matches') != 'none' ? 2 : 1)
->suffixAction(Action::make('reset')
->icon('phosphor-x-circle')
- ->action(fn (callable $set) => $set('similar_past_matches', 'none'))
- ->color(fn (Get $get): string => $get('similar_past_matches') != 'none' ? 'info' : 'gray'))
+ ->tooltip('Clear SMP')
+ ->action(fn(callable $set) => $set('similar_past_matches', 'none'))
+ ->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'danger' : 'gray'))
->placeholder('Similar Past Matches')
- ->suffix(fn (Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('
± '.$get('accuracy').'
') : '')
+ ->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('± ' . $get('accuracy') . '
') : '')
->prefix('SPM')
->prefixAction(
Action::make('iconInfo')
->icon('phosphor-question-fill')
- // ->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'success' : 'primary')
- ->color('success')
- ->tooltip(fn () => $this->tooltip_similar_past_matches())
+ ->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'success' : 'danger')
+ ->tooltip(fn() => $this->tooltip_similar_past_matches())
)
->default('none')
->selectablePlaceholder(false)
@@ -322,7 +327,7 @@ class Statistic extends BaseDashboard
Slider::make('accuracy')
->live()
->hiddenLabel()
- ->hidden(fn (Get $get) => $get('similar_past_matches') == 'none')
+ ->hidden(fn(Get $get) => $get('similar_past_matches') == 'none')
->fillTrack()
->minValue(0)
->maxValue(0.25)
@@ -342,13 +347,13 @@ class Statistic extends BaseDashboard
->allowHtml()
->columnSpan(2)
->placeholder('Player')
- ->visible(fn (Get $get) => $get('team_id'))
- ->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
- ->prefixIconColor(fn (Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '')
+ ->visible(fn(Get $get) => $get('team_id'))
+ ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
+ ->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '')
->prefixIcon('icon-player')
->preload()
->searchable()
- ->extraAttributes(fn () => [
+ ->extraAttributes(fn() => [
'id' => 'player_selector',
'style' => 'width: 100%;',
])
@@ -356,7 +361,7 @@ class Statistic extends BaseDashboard
Action::make('iconInfo')
->icon('phosphor-question-fill')
->color('success')
- ->tooltip(fn () => $this->tooltip_player_info())
+ ->tooltip(fn() => $this->tooltip_player_info())
)
->options(function (Get $get) {
$team_id = $get('team_id');
@@ -373,7 +378,7 @@ class Statistic extends BaseDashboard
->placeholder('Time on field')
->prefixIcon('phosphor-watch-fill')
->default('all')
- ->hidden(fn (Get $get) => ! $get('ss_player_id'))
+ ->hidden(fn(Get $get) => ! $get('ss_player_id'))
->prefixIconColor('success')
->selectablePlaceholder(false)
->options([
@@ -394,7 +399,7 @@ class Statistic extends BaseDashboard
->extraAttributes([
'class' => 'radio-statistic-group',
])
- ->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
+ ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->columnSpan(2)
->inline()
->default('season')
@@ -413,8 +418,8 @@ class Statistic extends BaseDashboard
->multiple()
->placeholder('Current Season')
->prefixIconColor('success')
- ->visible(fn (Get $get) => $get('seasonmode'))
- ->hidden(fn (Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
+ ->visible(fn(Get $get) => $get('seasonmode'))
+ ->hidden(fn(Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->prefixIcon('phosphor-calendar-star-fill')
->options([
'2026' => '2026',
@@ -434,8 +439,8 @@ class Statistic extends BaseDashboard
->multiple()
->placeholder('Current Season')
->prefixIconColor('success')
- ->visible(fn (Get $get) => $get('seasonmode'))
- ->hidden(fn (Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
+ ->visible(fn(Get $get) => $get('seasonmode'))
+ ->hidden(fn(Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
->prefixIcon('phosphor-calendar-star-fill')
->options([
'26/27' => '26/27',
@@ -451,44 +456,44 @@ class Statistic extends BaseDashboard
DatePicker::make('start_date')
->live()
->hiddenLabel()
- ->hidden(fn (Get $get) => $get('season_or_date') == 'season')
+ ->hidden(fn(Get $get) => $get('season_or_date') == 'season')
->native(false)
- ->prefixIconColor(fn (Get $get): string => $get('start_date') ? 'success' : 'primary')
+ ->prefixIconColor(fn(Get $get): string => $get('start_date') ? 'success' : 'primary')
->prefixIcon('phosphor-calendar-fill')
->prefix('Start')
->suffixAction(
Action::make('clear_start')
->icon('phosphor-x')
->color('gray')
- ->action(fn (Set $set) => $set('start_date', null))
+ ->action(fn(Set $set) => $set('start_date', null))
),
DatePicker::make('end_date')
->live()
->hiddenLabel()
- ->hidden(fn (Get $get) => $get('season_or_date') == 'season')
+ ->hidden(fn(Get $get) => $get('season_or_date') == 'season')
->native(false)
- ->prefixIconColor(fn (Get $get): string => $get('end_date') ? 'success' : 'primary')
+ ->prefixIconColor(fn(Get $get): string => $get('end_date') ? 'success' : 'primary')
->prefixIcon('phosphor-calendar-fill')
->prefix('End')
->suffixAction(
Action::make('clear_end')
->icon('phosphor-x')
->color('gray')
- ->action(fn (Set $set) => $set('end_date', null))
+ ->action(fn(Set $set) => $set('end_date', null))
),
Actions::make([
Action::make('esc')
->hiddenLabel()
- ->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
+ ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
->tooltip('Clear all (esc)')
->icon('phosphor-x-circle')
- ->color(fn (Get $get) => $get('sofascore_category_id') ? 'warning' : 'gray')
+ ->color(fn(Get $get) => $get('sofascore_category_id') ? 'warning' : 'gray')
->keyBindings(['esc'])
->action('resetFilters'),
Action::make('copy')
->hiddenLabel()
- ->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
- ->visible(fn (Get $get) => $get('team_id'))
+ ->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
+ ->visible(fn(Get $get) => $get('team_id'))
->tooltip('Copy data for pasting into spreadsheet')
->color('success')
->icon('phosphor-copy')
@@ -514,7 +519,7 @@ class Statistic extends BaseDashboard
$data = LoadEventsBoxes::load($this->filters, false);
$header = ['Team', 'Event', 'Odd 1', 'Odd X', 'Odd 2', 'Category', 'EXP H', 'EXP A', 'AGV+', 'AGV-', 'AGV Team Season H', 'AGV Team Season A', 'AGV League H', 'AGV League A'];
- $copystring = implode(';', $header)."\n";
+ $copystring = implode(';', $header) . "\n";
$row = [];
$row[] = $data['active_team'];
$row[] = $data['count_events'];
@@ -530,7 +535,7 @@ class Statistic extends BaseDashboard
$row[] = $data['gls_team_season']['away'];
$row[] = $data['gls_liga_season']['home'];
$row[] = $data['gls_liga_season']['away'];
- $copystring .= implode(';', $row)."\n";
+ $copystring .= implode(';', $row) . "\n";
$row = [];
$row = array_fill(0, 5, '');
$row[] = 'Fouls';
@@ -542,7 +547,7 @@ class Statistic extends BaseDashboard
$row[] = $data['fls_team_season']['away'];
$row[] = $data['fls_liga_season']['home'];
$row[] = $data['fls_liga_season']['away'];
- $copystring .= implode(';', $row)."\n";
+ $copystring .= implode(';', $row) . "\n";
$row = [];
$row = array_fill(0, 5, '');
$row[] = 'Offside';
@@ -554,7 +559,7 @@ class Statistic extends BaseDashboard
$row[] = $data['ofs_team_season']['away'];
$row[] = $data['ofs_liga_season']['home'];
$row[] = $data['ofs_liga_season']['away'];
- $copystring .= implode(';', $row)."\n";
+ $copystring .= implode(';', $row) . "\n";
$row = [];
$row = array_fill(0, 5, '');
$row[] = 'Cards';
@@ -566,7 +571,7 @@ class Statistic extends BaseDashboard
$row[] = $data['crd_team_season']['away'];
$row[] = $data['crd_liga_season']['home'];
$row[] = $data['crd_liga_season']['away'];
- $copystring .= implode(';', $row)."\n";
+ $copystring .= implode(';', $row) . "\n";
$row = [];
$row = array_fill(0, 5, '');
$row[] = 'Shots on traget';
@@ -578,7 +583,7 @@ class Statistic extends BaseDashboard
$row[] = $data['snt_team_season']['away'];
$row[] = $data['snt_liga_season']['home'];
$row[] = $data['snt_liga_season']['away'];
- $copystring .= implode(';', $row)."\n";
+ $copystring .= implode(';', $row) . "\n";
$row = [];
$row = array_fill(0, 5, '');
$row[] = 'Total Shots';
@@ -590,7 +595,7 @@ class Statistic extends BaseDashboard
$row[] = $data['tsh_team_season']['away'];
$row[] = $data['tsh_liga_season']['home'];
$row[] = $data['tsh_liga_season']['away'];
- $copystring .= implode(';', $row)."\n";
+ $copystring .= implode(';', $row) . "\n";
return $copystring;
}
diff --git a/app/Filament/Widgets/Boxes/LoadEventsBoxes.php b/app/Filament/Widgets/Boxes/LoadEventsBoxes.php
index 09b139e4..37618355 100644
--- a/app/Filament/Widgets/Boxes/LoadEventsBoxes.php
+++ b/app/Filament/Widgets/Boxes/LoadEventsBoxes.php
@@ -11,7 +11,6 @@ class LoadEventsBoxes
$league_id = (int) $filter['league_id'] ?? 0;
$match_id = (int) $filter['match_id'] ?? 0;
$team_id = (int) $filter['team_id'] ?? 0;
- $team_position = $filter['team_position'];
$similar_past_matches = $filter['similar_past_matches'];
if (! $league_id) {
@@ -20,9 +19,6 @@ class LoadEventsBoxes
if (! $match_id) {
return [];
}
- if (! $team_id) {
- return [];
- }
$match = StatisticFixtures::with('home')->with('away')->where('id', (int) $match_id)->first();
diff --git a/app/Filament/Widgets/BoxesBettypeAll.php b/app/Filament/Widgets/BoxesBettypeAll.php
index 4500cdd4..6da0d0ef 100644
--- a/app/Filament/Widgets/BoxesBettypeAll.php
+++ b/app/Filament/Widgets/BoxesBettypeAll.php
@@ -33,8 +33,6 @@ class BoxesBettypeAll extends StatsOverviewWidget
{
$data = LoadEventsBoxes::load($this->filters, false);
- // dd($data);
-
$similar_past_matches = $this->filters['similar_past_matches'];
$team_position = $this->filters['team_position'];
@@ -50,7 +48,7 @@ class BoxesBettypeAll extends StatsOverviewWidget
$count_events = $data['count_events'];
$boxes = [];
$boxes[] = Stat::make('Total', self::template_total($count_events))
- ->description(fn () => $similar_past_matches == 'none' ? 'Team Selected' : 'Similar Past Matches')
+ ->description(fn() => $similar_past_matches == 'none' ? 'Team Selected' : 'Similar Past Matches')
->extraAttributes(['x-init' => "animate('number-of-events', $count_events);", 'class' => 'box-success justify-center']);
// BOX 1X2
@@ -70,22 +68,22 @@ class BoxesBettypeAll extends StatsOverviewWidget
// BOX AVERAGE
if (isset($data['gls_team'])) {
- $boxes[] = Stat::make('Average '.$data['active_team'], self::template_tabelle_2($data))
+ $boxes[] = Stat::make('Average ' . $data['active_team'], self::template_tabelle_2($data))
->extraAttributes(['class' => 'box-blank'])
->description($team_position);
}
// BOX AVERAGE WITH TEAM FIXED TO ACTIVE SEASON
if (isset($data['gls_team_season'])) {
- $boxes[] = Stat::make('Average '.$data['active_team'], self::template_tabelle_3($data))
+ $boxes[] = Stat::make('Average ' . $data['active_team'], self::template_tabelle_3($data))
->extraAttributes(['class' => 'box-blank'])
- ->description('Season '.$data['active_season']);
+ ->description('Season ' . $data['active_season']);
}
// BOX AVERAGE ALL LEAGUE FIXED TO ACTIVE SEASON
if (isset($data['gls_liga_season'])) {
$boxes[] = Stat::make('League Average', self::template_tabelle_4($data))
->extraAttributes(['class' => 'box-blank'])
- ->description('Season '.$data['active_season']);
+ ->description('Season ' . $data['active_season']);
}
$this->columns = [
@@ -102,7 +100,7 @@ class BoxesBettypeAll extends StatsOverviewWidget
protected function template_total(float $total_home): HtmlString
{
return new HtmlString('
- '.$total_home.'
+ ' . $total_home . '
Events
');
}
@@ -111,22 +109,22 @@ class BoxesBettypeAll extends StatsOverviewWidget
protected function template_odds(array &$data, float $win, float $draw, float $lost): HtmlString
{
if ($this->filters['similar_past_matches'] != 'none') {
- $name_win = '1 ('.$data['win_count'].')';
- $name_draw = 'X ('.$data['draw_count'].')';
- $name_lost = '2 ('.$data['lost_count'].')';
+ $name_win = '1 (' . $data['win_count'] . ')';
+ $name_draw = 'X (' . $data['draw_count'] . ')';
+ $name_lost = '2 (' . $data['lost_count'] . ')';
} else {
- $name_win = 'Win ('.$data['win_count'].')';
- $name_draw = 'Draw ('.$data['draw_count'].')';
- $name_lost = 'Lost ('.$data['lost_count'].')';
+ $name_win = 'Win (' . $data['win_count'] . ')';
+ $name_draw = 'Draw (' . $data['draw_count'] . ')';
+ $name_lost = 'Lost (' . $data['lost_count'] . ')';
}
return new HtmlString('
- '.number_format($win, 2).'
- '.number_format($draw, 2).'
- '.number_format($lost, 2).'
- '.$name_win.'
- '.$name_draw.'
- '.$name_lost.'
+ ' . number_format($win, 2) . '
+ ' . number_format($draw, 2) . '
+ ' . number_format($lost, 2) . '
+ ' . $name_win . '
+ ' . $name_draw . '
+ ' . $name_lost . '
');
}
@@ -137,9 +135,9 @@ class BoxesBettypeAll extends StatsOverviewWidget
$str = '';
// $str .= '
Home
Away
';
foreach ($bets as $name) {
- $str .= '
'.$data[$name]['name'].'
';
- $str .= '
'.number_format($data[$name]['home'], 1).'
';
- $str .= '
'.number_format($data[$name]['away'], 1).'
';
+ $str .= '
' . $data[$name]['name'] . '
';
+ $str .= '
' . number_format($data[$name]['home'], 1) . '
';
+ $str .= '
' . number_format($data[$name]['away'], 1) . '
';
}
$str .= '
';
@@ -152,9 +150,9 @@ class BoxesBettypeAll extends StatsOverviewWidget
$str = '';
// $str .= '
Home
Away
';
foreach ($bets as $name) {
- $str .= '
'.$data[$name]['name'].'
';
- $str .= '
'.number_format($data[$name]['home'], 1).'
';
- $str .= '
'.number_format($data[$name]['away'], 1).'
';
+ $str .= '
' . $data[$name]['name'] . '
';
+ $str .= '
' . number_format($data[$name]['home'], 1) . '
';
+ $str .= '
' . number_format($data[$name]['away'], 1) . '
';
}
$str .= '
';
@@ -167,9 +165,9 @@ class BoxesBettypeAll extends StatsOverviewWidget
$str = '';
// $str .= '
Home
Away
';
foreach ($bets as $name) {
- $str .= '
'.$data[$name]['name'].'
';
- $str .= '
'.number_format($data[$name]['home'], 1).'
';
- $str .= '
'.number_format($data[$name]['away'], 1).'
';
+ $str .= '
' . $data[$name]['name'] . '
';
+ $str .= '
' . number_format($data[$name]['home'], 1) . '
';
+ $str .= '
' . number_format($data[$name]['away'], 1) . '
';
}
$str .= '
';
@@ -182,9 +180,9 @@ class BoxesBettypeAll extends StatsOverviewWidget
$str = '';
// $str .= '
Home
Away
';
foreach ($bets as $name) {
- $str .= '
'.$data[$name]['name'].'
';
- $str .= '
'.number_format($data[$name]['home'], 1).'
';
- $str .= '
'.number_format($data[$name]['away'], 1).'
';
+ $str .= '
' . $data[$name]['name'] . '
';
+ $str .= '
' . number_format($data[$name]['home'], 1) . '
';
+ $str .= '
' . number_format($data[$name]['away'], 1) . '
';
}
$str .= '
';
diff --git a/app/Services/CloudflareSolverService.php b/app/Services/CloudflareSolverService.php
index 50f1ea6b..33a8a36f 100644
--- a/app/Services/CloudflareSolverService.php
+++ b/app/Services/CloudflareSolverService.php
@@ -38,6 +38,10 @@ class CloudflareSolverService
$data = $response->json();
+ $tmp = json_encode($data);
+ // if (strpos($tmp, "reason") !== false && strpos($tmp, 403) !== false)
+ // dd($data);
+
if (isset($data['status']) && $data['status'] === 'ok') {
$htmlContent = $data['solution']['response'];
diff --git a/app/Traits/Sofascore/GrapSofascore.php b/app/Traits/Sofascore/GrapSofascore.php
index 68df9ed0..960041e2 100644
--- a/app/Traits/Sofascore/GrapSofascore.php
+++ b/app/Traits/Sofascore/GrapSofascore.php
@@ -4,6 +4,7 @@ namespace App\Traits\Sofascore;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
+use Illuminate\Support\Facades\File;
use function Laravel\Prompts\select;
use function Laravel\Prompts\text;
@@ -62,9 +63,7 @@ trait GrapSofascore
switch ($grapperSelected) {
case 'daily':
$this->task_id = 1;
-
$this->days_back = (int) $this->select_day();
-
$this->run_daily($grapperSelected);
break;
@@ -76,16 +75,19 @@ trait GrapSofascore
case 'settings':
$this->settings_to_local();
break;
+
case 'excel':
$folder = $this->select_folder();
$this->import_to_excel($folder);
break;
+
case 'mail':
$folder = $this->select_folder();
$this->send($folder);
break;
+
case 'clear':
$folder = $this->select_folder();
@@ -117,7 +119,16 @@ trait GrapSofascore
$this->load_tournaments_requested($folder);
- $this->clear_folder($folder, 'all');
+ $restart = $this->ask_restart();
+ switch ($restart) {
+ case 'restart':
+ $this->restart = 1;
+ break;
+ case 'clear':
+ $this->restart = 1;
+ $this->clear_folder($folder, 'all');
+ break;
+ }
/**
* day 1
@@ -196,12 +207,18 @@ trait GrapSofascore
$this->set_base_dir($folder);
$restart = $this->ask_restart();
-
- if ($restart == 'yes') {
- $this->restart = 1;
- $this->clear_folder($folder, 'all');
+ switch ($restart) {
+ case 'restart':
+ $this->restart = 1;
+ break;
+ case 'clear':
+ $this->restart = 1;
+ $this->clear_folder($folder, 'all');
+ break;
}
+ $day_done = $this->days_done();
+
$this->load_tournaments_requested($folder);
$this->load_days($folder);
@@ -213,10 +230,16 @@ trait GrapSofascore
Notice::note("$key/$count", 'br');
}
- $this->grap_tournaments_for_day($day);
+ if (in_array($day, $day_done)) {
+ if ($this->debug) {
+ Notice::note("$day already in folder", 'br');
+ }
+ } else {
+ $this->grap_tournaments_for_day($day);
- foreach ($this->tournaments_requested as $tournament) {
- $this->get_event($day, $tournament);
+ foreach ($this->tournaments_requested as $tournament) {
+ $this->get_event($day, $tournament);
+ }
}
}
@@ -225,6 +248,16 @@ trait GrapSofascore
Notice::note('Done', 'g');
}
+ protected function days_done(): array
+ {
+ $directories = File::directories($this->data_dir);
+ $arr = [];
+ foreach ($directories as $directory) {
+ $arr[] = substr(strrchr($directory, "/"), 1);
+ }
+ return $arr;
+ }
+
/**
* Summary of select_grapper
*/
@@ -279,8 +312,9 @@ trait GrapSofascore
label: 'Restart Grapper?',
default: 'no',
options: [
- 'yes' => 'Yes',
'no' => 'No',
+ 'restart' => 'Restart',
+ 'clear' => 'Clear folder and restart',
]
);
}
diff --git a/app/Traits/Sofascore/GrapperEvent.php b/app/Traits/Sofascore/GrapperEvent.php
index 0089032a..0da16d17 100644
--- a/app/Traits/Sofascore/GrapperEvent.php
+++ b/app/Traits/Sofascore/GrapperEvent.php
@@ -19,15 +19,15 @@ trait GrapperEvent
if ($res) {
if ($this->debug) {
- Notice::note("$day - ".$tournament['tournament']['name'].' - '.$tournament['sofa_score_tournament_id'], 'b');
+ Notice::note("$day - " . $tournament['tournament']['name'] . ' - ' . $tournament['sofa_score_tournament_id'], 'bb');
}
$this->sleep(1);
- $url = $this->base_url.'api/v1/unique-tournament/'.$tournament['sofa_score_tournament_id']."/scheduled-events/$day";
+ $url = $this->base_url . 'api/v1/unique-tournament/' . $tournament['sofa_score_tournament_id'] . "/scheduled-events/$day";
if ($this->debug) {
- Notice::note($url, 'bb');
+ Notice::note($url, 'b');
}
$this->sleep(1);
@@ -40,17 +40,17 @@ trait GrapperEvent
foreach ($data['events'] as $event) {
- if (! $this->force && SofaScoreEventGrapped::where('grapper_id', $this->task_id)->where('id', (int) $event['id'])->exists()) {
+ if (! $this->restart && SofaScoreEventGrapped::where('grapper_id', $this->task_id)->where('id', (int) $event['id'])->exists()) {
if ($this->debug) {
- Notice::note('DB - Allready grapped at '.$day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'b');
+ Notice::note('DB - Allready grapped at ' . $day . ' - ' . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'b');
}
} else {
if ($this->debug) {
- Notice::note("$day - ".$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'g');
+ Notice::note("$day - " . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'g');
}
- $folder = strtolower("$this->data_dir/$day/$day-".$event['tournament']['category']['slug'].'-'.$event['tournament']['slug'].'/'.$event['slug']);
+ $folder = strtolower("$this->data_dir/$day/$day-" . $event['tournament']['category']['slug'] . '-' . $event['tournament']['slug'] . '/' . $event['slug']);
File::makeDirectory($folder, 0775, true, true);
@@ -66,7 +66,7 @@ trait GrapperEvent
$event_id = $event['id'];
- $url = $this->base_url."api/v1/event/$event_id/statistics";
+ $url = $this->base_url . "api/v1/event/$event_id/statistics";
if ($this->debug) {
Notice::note($url, 'b');
@@ -84,7 +84,7 @@ trait GrapperEvent
* EVENT lineups
*********************************/
- $url = $this->base_url."api/v1/event/$event_id/lineups";
+ $url = $this->base_url . "api/v1/event/$event_id/lineups";
if ($this->debug) {
Notice::note($url, 'b');
@@ -102,7 +102,7 @@ trait GrapperEvent
* EVENT odds
*********************************/
- $url = $this->base_url."api/v1/event/$event_id/odds/1/all";
+ $url = $this->base_url . "api/v1/event/$event_id/odds/1/all";
if ($this->debug) {
Notice::note($url, 'b');
@@ -120,7 +120,7 @@ trait GrapperEvent
* EVENT incidents
*********************************/
- $url = $this->base_url."api/v1/event/$event_id/incidents";
+ $url = $this->base_url . "api/v1/event/$event_id/incidents";
if ($this->debug) {
Notice::note($url, 'b');
@@ -142,7 +142,7 @@ trait GrapperEvent
'grapper_id' => $this->task_id,
'day' => $day,
'liga' => $event['tournament']['name'],
- 'name' => $event['homeTeam']['name'].' vs '.$event['awayTeam']['name'],
+ 'name' => $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'],
'url' => $url,
'starttime' => $starttime->toDateTimeString(),
]);
diff --git a/app/Traits/Sofascore/GrappingHelper.php b/app/Traits/Sofascore/GrappingHelper.php
index 0bef1786..3be0bd64 100644
--- a/app/Traits/Sofascore/GrappingHelper.php
+++ b/app/Traits/Sofascore/GrappingHelper.php
@@ -73,19 +73,19 @@ trait GrappingHelper
break;
}
- if ($this->restart) {
- SofaScoreEventGrapped::where('grapper_id', $this->task_id)->delete();
+ // if ($this->restart) {
+ // SofaScoreEventGrapped::where('grapper_id', $this->task_id)->delete();
- foreach ($this->days as $day) {
- // if restarting find position
- SofaScoreTaskDay::where('grapper_id', 1)
- ->where('day', $day)
- ->update(['done' => 0]);
- }
- if ($this->debug) {
- Notice::note('Grapper restarted', 'r', 1);
- }
- }
+ // foreach ($this->days as $day) {
+ // // if restarting find position
+ // SofaScoreTaskDay::where('grapper_id', 1)
+ // ->where('day', $day)
+ // ->update(['done' => 0]);
+ // }
+ // if ($this->debug) {
+ // Notice::note('Grapper restarted', 'r', 1);
+ // }
+ // }
$this->days = array_unique($this->days, SORT_REGULAR);
}
@@ -97,16 +97,16 @@ trait GrappingHelper
{
switch ($grapperSelected) {
case 'daily':
- $this->data_dir = storage_path($this->base_dir).'/daily';
+ $this->data_dir = storage_path($this->base_dir) . '/daily';
break;
case 'range':
- $this->data_dir = storage_path($this->base_dir).'/range';
+ $this->data_dir = storage_path($this->base_dir) . '/range';
break;
case 'rose':
- $this->data_dir = storage_path($this->base_dir).'/rose';
+ $this->data_dir = storage_path($this->base_dir) . '/rose';
break;
case 'player':
- $this->data_dir = storage_path($this->base_dir).'/player';
+ $this->data_dir = storage_path($this->base_dir) . '/player';
break;
case 'excel':
case 'mail':
@@ -231,7 +231,7 @@ trait GrappingHelper
if (! $this->force && $has) {
if ($this->debug) {
- Notice::note("tournaments $day for ".strtoupper($slug).' allready grapped', 'bb');
+ Notice::note("tournaments $day for " . strtoupper($slug) . ' allready grapped', 'bb');
}
} else {
@@ -246,7 +246,7 @@ trait GrappingHelper
$this->sleep();
- $url = $this->base_url."api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
+ $url = $this->base_url . "api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
$cloudflareService = new CloudflareSolverService;
@@ -372,7 +372,7 @@ trait GrappingHelper
{
$files = scandir($dir);
foreach ($files as $value) {
- $path = realpath($dir.DIRECTORY_SEPARATOR.$value);
+ $path = realpath($dir . DIRECTORY_SEPARATOR . $value);
if (! is_dir($path)) {
$results[] = $path;
} elseif ($value != '.' && $value != '..') {
@@ -395,7 +395,7 @@ trait GrappingHelper
protected function clear_folder(string $folder, $what = '')
{
- $mainFolder = storage_path($this->base_dir.'/'.$folder);
+ $mainFolder = storage_path($this->base_dir . '/' . $folder);
if (! $what) {
$what = $this->select_what_delete();
@@ -426,8 +426,8 @@ trait GrappingHelper
$tasks = StatistikoImport::pluck('file_name')->toArray();
collect(Storage::disk('public')->allFiles('statistiko'))
- ->reject(fn (string $file) => $file === '.gitignore')
- ->reject(fn (string $file) => in_array($file, $tasks))
- ->each(fn ($file) => Storage::disk('public')->delete($file));
+ ->reject(fn(string $file) => $file === '.gitignore')
+ ->reject(fn(string $file) => in_array($file, $tasks))
+ ->each(fn($file) => Storage::disk('public')->delete($file));
}
}
diff --git a/app/Traits/Sofascore/GrappingToExcel.php b/app/Traits/Sofascore/GrappingToExcel.php
index a5c2ebea..ad4ac4f8 100644
--- a/app/Traits/Sofascore/GrappingToExcel.php
+++ b/app/Traits/Sofascore/GrappingToExcel.php
@@ -19,66 +19,77 @@ trait GrappingToExcel
ini_set('memory_limit', -1);
if ($this->debug) {
- Notice::note("Import to Excel", 'bb');
+ Notice::note("Import $folder to Excel", 'bb');
}
- $directories = File::directories($this->data_dir . '/' . $folder);
-
- foreach ($directories as $directory) {
-
- $day = substr(strrchr($directory, "/"), 1);
-
- $this->titel = ucfirst($folder) . '-' . $day;
-
- $files = $this->get_tree($directory);
-
- // only json max 2000
- $files = array_chunk($this->filter($files), $this->max);
-
- foreach ($files as $key => $value) {
-
- $has = count($value);
- if (! $key && $has < $this->max) {
- $count_from = 1;
- $count_to = $has;
- } elseif (! $key) {
- $count_from = 1;
- $key++;
- $count_to = $key * $this->max;
- } elseif ($has == $this->max) {
- $count_from = $key * $this->max + 1;
- $key++;
- $count_to = $key * $this->max;
- } else {
- $count_from = $key * $this->max + 1;
- $count_to = $key * $this->max + $has;
+ switch ($folder) {
+ case 'daily':
+ $directories = File::directories($this->data_dir);
+ foreach ($directories as $directory) {
+ $day = substr(strrchr($directory, "/"), 1);
+ $this->titel = ucfirst($folder) . '-' . $day;
+ $this->make_file($this->data_dir . '/' . $day);
}
+ break;
- $spreadsheet = new Spreadsheet;
- $spreadsheet->getProperties()->setTitle($this->titel . '-' . $count_from . '-' . $count_to);
- $activeWorksheet = $spreadsheet->getActiveSheet();
+ case 'range':
+ $task = SofaScoreTask::with('sport')->where('id', 3)->first();
+ $this->titel = ucfirst($folder) . '-' . $this->clean_string($task->name);
+ $this->make_file($this->data_dir);
+ break;
+ }
+ }
- $column = 1;
- foreach ($value as $file) {
- $data = file_get_contents($file);
- $data = json_decode($data, true);
- $json_string = json_encode($data, JSON_PRETTY_PRINT);
+ protected function make_file(string $directory)
+ {
+ $files = $this->get_tree($directory);
- $arr = explode(PHP_EOL, $json_string);
- $row = 0;
- foreach ($arr as $string) {
- $row++;
- $replacedString = preg_replace('/\\\\u([0-9abcdef]{4})/', '$1;', $string);
- $utf8string = mb_convert_encoding($replacedString, 'UTF-8', 'HTML-ENTITIES');
- $activeWorksheet->setCellValue([$column, $row], $utf8string);
- }
- $column++;
- }
+ // only json max 2000
+ $files = array_chunk($this->filter($files), $this->max);
- $spreadsheet->setActiveSheetIndex(0);
- $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
- $writer->save("$this->data_dir/$this->titel-$count_from-$count_to.xlsx");
+ foreach ($files as $key => $value) {
+
+ $has = count($value);
+ if (! $key && $has < $this->max) {
+ $count_from = 1;
+ $count_to = $has;
+ } elseif (! $key) {
+ $count_from = 1;
+ $key++;
+ $count_to = $key * $this->max;
+ } elseif ($has == $this->max) {
+ $count_from = $key * $this->max + 1;
+ $key++;
+ $count_to = $key * $this->max;
+ } else {
+ $count_from = $key * $this->max + 1;
+ $count_to = $key * $this->max + $has;
}
+
+ $spreadsheet = new Spreadsheet;
+ $spreadsheet->getProperties()->setTitle($this->titel . '-' . $count_from . '-' . $count_to);
+ $activeWorksheet = $spreadsheet->getActiveSheet();
+
+ $column = 1;
+ foreach ($value as $file) {
+ $data = file_get_contents($file);
+ $data = json_decode($data, true);
+ $json_string = json_encode($data, JSON_PRETTY_PRINT);
+
+ $arr = explode(PHP_EOL, $json_string);
+ $row = 0;
+ foreach ($arr as $string) {
+ $row++;
+ $replacedString = preg_replace('/\\\\u([0-9abcdef]{4})/', '$1;', $string);
+ $utf8string = mb_convert_encoding($replacedString, 'UTF-8', 'HTML-ENTITIES');
+ $activeWorksheet->setCellValue([$column, $row], $utf8string);
+ }
+ $column++;
+ }
+
+ $spreadsheet->setActiveSheetIndex(0);
+ $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
+ $writer->save("$this->data_dir/$this->titel-$count_from-$count_to.xlsx");
}
}
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 8c3b6fcb..37c0f3a5 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -1,11 +1,12 @@
services:
- flaresolverr-server:
- image: flaresolverr/flaresolverr:latest # Aktualisiert auf die neueste Version
- container_name: flaresolverr_standalone
- ports:
- - "8191:8191"
- environment:
- - LOG_LEVEL=info
- - TZ=Europe/Vienna
- - HOST=0.0.0.0
- restart: always
+ flaresolverr-server:
+ image: flaresolverr/flaresolverr:latest # Aktualisiert auf die neueste Version
+ container_name: flaresolverr_standalone
+ ports:
+ - "8191:8191"
+ environment:
+ - LOG_LEVEL=info
+ - TZ=Europe/Vienna
+ - LANG=en-US
+ - HOST=0.0.0.0
+ restart: always