Compare commits
11
Commits
3034b54947
...
5fa0056b8b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fa0056b8b | ||
|
|
916fb91895 | ||
|
|
74ff567cce | ||
|
|
6f92f9e1d5 | ||
|
|
9bcd4432c6 | ||
|
|
812736ca9a | ||
|
|
fbde80c898 | ||
|
|
cf55e1e218 | ||
|
|
f6a7ebf737 | ||
|
|
0e37c23e97 | ||
|
|
d0e17cdc03 |
No files matched your search
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Traits\Sofascore\GrapSofascore;
|
||||
use App\Traits\Sofascore\GrappingSofascore;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Grapper extends Command
|
||||
{
|
||||
use GrapSofascore;
|
||||
use GrappingSofascore;
|
||||
|
||||
protected $signature = 'grp:sofa {--d} {--r} {--f}';
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Traits\Sofascore\GrapSofascore;
|
||||
use App\Traits\Sofascore\GrappingSofascore;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class GrapperDaily extends Command
|
||||
{
|
||||
use GrapSofascore;
|
||||
use GrappingSofascore;
|
||||
|
||||
protected $signature = 'grp:daily {--d} {--r} {--f}';
|
||||
|
||||
|
||||
@@ -140,10 +140,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')
|
||||
->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'));
|
||||
@@ -156,10 +156,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')
|
||||
->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);
|
||||
@@ -170,8 +170,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')
|
||||
->options(function (Get $get) {
|
||||
return LoadStatisticFixturesMatchOptions::load($get('league_id'));
|
||||
@@ -184,7 +184,7 @@ class Statistic extends BaseDashboard
|
||||
->placeholder('Select Event'),
|
||||
Action::make('esc')
|
||||
->hiddenLabel()
|
||||
->visible(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->visible(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->tooltip('Clear All (esc)')
|
||||
->icon('phosphor-x-circle')
|
||||
->color('danger')
|
||||
@@ -209,9 +209,9 @@ class Statistic extends BaseDashboard
|
||||
->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')
|
||||
->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();
|
||||
@@ -247,9 +247,9 @@ class Statistic extends BaseDashboard
|
||||
Action::make('iconInfo')
|
||||
->color('success')
|
||||
->icon('phosphor-question')
|
||||
->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([
|
||||
@@ -296,21 +296,21 @@ class Statistic extends BaseDashboard
|
||||
->live()
|
||||
// ->columnSpan(2)
|
||||
->hiddenLabel()
|
||||
->hidden(fn(Get $get) => $get('team_id') != null)
|
||||
->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')
|
||||
->tooltip('Clear SMP')
|
||||
->action(fn(callable $set) => $set('similar_past_matches', 'none'))
|
||||
->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'danger' : 'gray'))
|
||||
->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('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± ' . $get('accuracy') . '</div>') : '')
|
||||
->suffix(fn (Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± '.$get('accuracy').'</div>') : '')
|
||||
->prefix('SPM')
|
||||
->prefixAction(
|
||||
Action::make('iconInfo')
|
||||
->icon('phosphor-question')
|
||||
->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'success' : 'danger')
|
||||
->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)
|
||||
@@ -330,7 +330,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)
|
||||
@@ -350,13 +350,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%;',
|
||||
])
|
||||
@@ -364,7 +364,7 @@ class Statistic extends BaseDashboard
|
||||
Action::make('iconInfo')
|
||||
->icon('phosphor-question')
|
||||
->color('success')
|
||||
->tooltip(fn() => $this->tooltip_player_info())
|
||||
->tooltip(fn () => $this->tooltip_player_info())
|
||||
)
|
||||
->options(function (Get $get) {
|
||||
$team_id = $get('team_id');
|
||||
@@ -381,7 +381,7 @@ class Statistic extends BaseDashboard
|
||||
->placeholder('Time on field')
|
||||
->prefixIcon('phosphor-watch')
|
||||
->default('all')
|
||||
->hidden(fn(Get $get) => ! $get('ss_player_id'))
|
||||
->hidden(fn (Get $get) => ! $get('ss_player_id'))
|
||||
->prefixIconColor('success')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
@@ -402,7 +402,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')
|
||||
@@ -421,8 +421,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')
|
||||
->options([
|
||||
'2026' => '2026',
|
||||
@@ -442,8 +442,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')
|
||||
->options([
|
||||
'26/27' => '26/27',
|
||||
@@ -459,46 +459,46 @@ 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')
|
||||
->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')
|
||||
->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') ? 'danger' : 'gray')
|
||||
->color(fn (Get $get) => $get('sofascore_category_id') ? 'danger' : 'gray')
|
||||
->keyBindings(['esc'])
|
||||
->outlined()
|
||||
->size(Size::Medium)
|
||||
->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')
|
||||
->size(Size::Medium)
|
||||
@@ -521,12 +521,15 @@ class Statistic extends BaseDashboard
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of generateDynamicPayload
|
||||
*/
|
||||
public function generateDynamicPayload(): string
|
||||
{
|
||||
$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'];
|
||||
@@ -542,7 +545,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';
|
||||
@@ -554,7 +557,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';
|
||||
@@ -566,7 +569,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';
|
||||
@@ -578,7 +581,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';
|
||||
@@ -590,7 +593,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';
|
||||
@@ -602,7 +605,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;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Filament\Widgets\Boxes\Helper\ExpectationCalculation;
|
||||
use App\Filament\Widgets\Boxes\Helper\ExpectationCollecting;
|
||||
use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll;
|
||||
use App\Utilities\Round;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ExpectationsTeam
|
||||
{
|
||||
@@ -29,20 +30,24 @@ class ExpectationsTeam
|
||||
}
|
||||
|
||||
$res = LoadEventsQueryAll::load($filter, $match);
|
||||
|
||||
$count_events = $res->count();
|
||||
if (! $res) {
|
||||
return [];
|
||||
}
|
||||
$tmp = [];
|
||||
foreach ($res as $value) {
|
||||
ExpectationCollecting::sort($tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'crd', $value->home_id, $value->away_id, $value->crd_h, $value->crd_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'snt', $value->home_id, $value->away_id, $value->snt_h, $value->snt_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'tsh', $value->home_id, $value->away_id, $value->tsh_h, $value->tsh_a, $match);
|
||||
ExpectationCollecting::sort($tmp, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match);
|
||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
|
||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match);
|
||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match);
|
||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'crd', $value->home_id, $value->away_id, $value->crd_h, $value->crd_a, $match);
|
||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'snt', $value->home_id, $value->away_id, $value->snt_h, $value->snt_a, $match);
|
||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'tsh', $value->home_id, $value->away_id, $value->tsh_h, $value->tsh_a, $match);
|
||||
ExpectationCollecting::sort($similar_past_matches, $tmp, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match);
|
||||
}
|
||||
|
||||
// Log::debug('expectations '.$count_events, $tmp);
|
||||
|
||||
$expectations = ExpectationCalculation::calc($tmp);
|
||||
$expectations['gls']['name'] = 'Goals';
|
||||
$expectations['fls']['name'] = 'Fouls';
|
||||
@@ -53,6 +58,8 @@ class ExpectationsTeam
|
||||
$expectations['home'] = $home_team;
|
||||
$expectations['away'] = $away_team;
|
||||
|
||||
// Log::debug('expectations '.$count_events, $expectations);
|
||||
|
||||
$expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0];
|
||||
foreach ($res as $value) {
|
||||
if ($team_id && $team_position == 'home') {
|
||||
|
||||
@@ -4,43 +4,47 @@ namespace App\Filament\Widgets\Boxes\Helper;
|
||||
|
||||
class ExpectationCollecting
|
||||
{
|
||||
public static function sort(array &$result, string $type, int $home_id, int $away_id, float $val_home, float $val_away, object $match)
|
||||
public static function sort(string $similar_past_matches, array &$result, string $type, int $home_id, int $away_id, float $val_home, float $val_away, object $match)
|
||||
{
|
||||
|
||||
if ($home_id == $match->home_id) {
|
||||
if ($similar_past_matches != 'none') {
|
||||
$result[$type.'_home_made_total'][] = $val_home;
|
||||
$result[$type.'_home_made_home'][] = $val_home;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
$result[$type.'_home_got_home'][] = $val_away;
|
||||
} elseif ($away_id == $match->home_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_away;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
} elseif ($home_id == $match->away_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_away;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
} elseif ($away_id == $match->away_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_home;
|
||||
$result[$type.'_home_made_home'][] = $val_home;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
$result[$type.'_home_got_home'][] = $val_home;
|
||||
}
|
||||
$result[$type.'_away_made_total'][] = $val_away;
|
||||
} else {
|
||||
if ($home_id == $match->home_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_home;
|
||||
$result[$type.'_home_made_home'][] = $val_home;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
$result[$type.'_home_got_home'][] = $val_away;
|
||||
} elseif ($away_id == $match->home_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_away;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
} elseif ($home_id == $match->away_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_away;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
} elseif ($away_id == $match->away_id) {
|
||||
$result[$type.'_home_made_total'][] = $val_home;
|
||||
$result[$type.'_home_made_home'][] = $val_home;
|
||||
$result[$type.'_home_got_total'][] = $val_away;
|
||||
$result[$type.'_home_got_home'][] = $val_home;
|
||||
}
|
||||
|
||||
if ($away_id == $match->away_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_away;
|
||||
$result[$type.'_away_made_home'][] = $val_away;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
$result[$type.'_away_got_home'][] = $val_home;
|
||||
} elseif ($home_id == $match->away_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_home;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
} elseif ($away_id == $match->home_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_home;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
} elseif ($home_id == $match->home_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_away;
|
||||
$result[$type.'_away_made_home'][] = $val_away;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
$result[$type.'_away_got_home'][] = $val_away;
|
||||
if ($away_id == $match->away_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_away;
|
||||
$result[$type.'_away_made_home'][] = $val_away;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
$result[$type.'_away_got_home'][] = $val_home;
|
||||
} elseif ($home_id == $match->away_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_home;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
} elseif ($away_id == $match->home_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_home;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
} elseif ($home_id == $match->home_id) {
|
||||
$result[$type.'_away_made_total'][] = $val_away;
|
||||
$result[$type.'_away_made_home'][] = $val_away;
|
||||
$result[$type.'_away_got_total'][] = $val_home;
|
||||
$result[$type.'_away_got_home'][] = $val_away;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ class BoxesBettypeAll extends StatsOverviewWidget
|
||||
{
|
||||
use InteractsWithPageFilters;
|
||||
|
||||
// Within your Widget class:
|
||||
protected ?string $pollingInterval = null;
|
||||
|
||||
protected int|array|null $columns = null;
|
||||
@@ -33,6 +34,8 @@ 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'];
|
||||
|
||||
@@ -48,7 +51,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
|
||||
@@ -68,22 +71,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 = [
|
||||
@@ -100,7 +103,7 @@ class BoxesBettypeAll extends StatsOverviewWidget
|
||||
protected function template_total(float $total_home): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="grid grid-cols-1 justify-center font-bold text-2xl">
|
||||
<span class="text-center" id="number-of-events">' . $total_home . '</span>
|
||||
<span class="text-center" id="number-of-events">'.$total_home.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">Events</span>
|
||||
</div>');
|
||||
}
|
||||
@@ -109,22 +112,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 = '<b>1</b> (' . $data['win_count'] . ')';
|
||||
$name_draw = '<b>X</b> (' . $data['draw_count'] . ')';
|
||||
$name_lost = '<b>2</b> (' . $data['lost_count'] . ')';
|
||||
$name_win = '<b>1</b> ('.$data['win_count'].')';
|
||||
$name_draw = '<b>X</b> ('.$data['draw_count'].')';
|
||||
$name_lost = '<b>2</b> ('.$data['lost_count'].')';
|
||||
} else {
|
||||
$name_win = '<b>Win</b> (' . $data['win_count'] . ')';
|
||||
$name_draw = '<b>Draw</b> (' . $data['draw_count'] . ')';
|
||||
$name_lost = '<b>Lost</b> (' . $data['lost_count'] . ')';
|
||||
$name_win = '<b>Win</b> ('.$data['win_count'].')';
|
||||
$name_draw = '<b>Draw</b> ('.$data['draw_count'].')';
|
||||
$name_lost = '<b>Lost</b> ('.$data['lost_count'].')';
|
||||
}
|
||||
|
||||
return new HtmlString('<div class="grid grid-cols-3 gap-3">
|
||||
<span class="text-center font-bold text-xl" id="win">' . number_format($win, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl" id="draw">' . number_format($draw, 2) . '</span>
|
||||
<span class="text-center font-bold text-xl" id="lost">' . number_format($lost, 2) . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_win . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_draw . '</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">' . $name_lost . '</span>
|
||||
<span class="text-center font-bold text-xl" id="win">'.number_format($win, 2).'</span>
|
||||
<span class="text-center font-bold text-xl" id="draw">'.number_format($draw, 2).'</span>
|
||||
<span class="text-center font-bold text-xl" id="lost">'.number_format($lost, 2).'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$name_win.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$name_draw.'</span>
|
||||
<span class="text-center text-xs text-gray-500 dark:text-gray-400">'.$name_lost.'</span>
|
||||
</div>');
|
||||
}
|
||||
|
||||
@@ -135,9 +138,9 @@ class BoxesBettypeAll extends StatsOverviewWidget
|
||||
$str = '<div class="grid grid-cols-4 gap-0.5 text-xs">';
|
||||
// $str .= '<div class="col-span-2"></div><div>Home</div><div>Away</div>';
|
||||
foreach ($bets as $name) {
|
||||
$str .= '<div class="font-normal text-left col-span-2">' . $data[$name]['name'] . '</div>';
|
||||
$str .= '<div class="text-right">' . number_format($data[$name]['home'], 1) . '</div>';
|
||||
$str .= '<div class="text-right">' . number_format($data[$name]['away'], 1) . '</div>';
|
||||
$str .= '<div class="font-normal text-left col-span-2">'.$data[$name]['name'].'</div>';
|
||||
$str .= '<div class="text-right">'.number_format($data[$name]['home'], 1).'</div>';
|
||||
$str .= '<div class="text-right">'.number_format($data[$name]['away'], 1).'</div>';
|
||||
}
|
||||
$str .= '</div>';
|
||||
|
||||
@@ -150,9 +153,9 @@ class BoxesBettypeAll extends StatsOverviewWidget
|
||||
$str = '<div class="grid grid-cols-4 gap-0.5 text-xs">';
|
||||
// $str .= '<div class="col-span-2"></div><div>Home</div><div>Away</div>';
|
||||
foreach ($bets as $name) {
|
||||
$str .= '<div class="font-normal text-left col-span-2">' . $data[$name]['name'] . '</div>';
|
||||
$str .= '<div class="text-right">' . number_format($data[$name]['home'], 1) . '</div>';
|
||||
$str .= '<div class="text-right">' . number_format($data[$name]['away'], 1) . '</div>';
|
||||
$str .= '<div class="font-normal text-left col-span-2">'.$data[$name]['name'].'</div>';
|
||||
$str .= '<div class="text-right">'.number_format($data[$name]['home'], 1).'</div>';
|
||||
$str .= '<div class="text-right">'.number_format($data[$name]['away'], 1).'</div>';
|
||||
}
|
||||
$str .= '</div>';
|
||||
|
||||
@@ -165,9 +168,9 @@ class BoxesBettypeAll extends StatsOverviewWidget
|
||||
$str = '<div class="grid grid-cols-4 gap-0.5 text-xs">';
|
||||
// $str .= '<div class="col-span-2"></div><div>Home</div><div>Away</div>';
|
||||
foreach ($bets as $name) {
|
||||
$str .= '<div class="font-normal text-left col-span-2">' . $data[$name]['name'] . '</div>';
|
||||
$str .= '<div class="text-right">' . number_format($data[$name]['home'], 1) . '</div>';
|
||||
$str .= '<div class="text-right">' . number_format($data[$name]['away'], 1) . '</div>';
|
||||
$str .= '<div class="font-normal text-left col-span-2">'.$data[$name]['name'].'</div>';
|
||||
$str .= '<div class="text-right">'.number_format($data[$name]['home'], 1).'</div>';
|
||||
$str .= '<div class="text-right">'.number_format($data[$name]['away'], 1).'</div>';
|
||||
}
|
||||
$str .= '</div>';
|
||||
|
||||
@@ -180,9 +183,9 @@ class BoxesBettypeAll extends StatsOverviewWidget
|
||||
$str = '<div class="grid grid-cols-4 gap-0.5 text-xs">';
|
||||
// $str .= '<div class="col-span-2"></div><div>Home</div><div>Away</div>';
|
||||
foreach ($bets as $name) {
|
||||
$str .= '<div class="font-normal text-left col-span-2">' . $data[$name]['name'] . '</div>';
|
||||
$str .= '<div class="text-right">' . number_format($data[$name]['home'], 1) . '</div>';
|
||||
$str .= '<div class="text-right">' . number_format($data[$name]['away'], 1) . '</div>';
|
||||
$str .= '<div class="font-normal text-left col-span-2">'.$data[$name]['name'].'</div>';
|
||||
$str .= '<div class="text-right">'.number_format($data[$name]['home'], 1).'</div>';
|
||||
$str .= '<div class="text-right">'.number_format($data[$name]['away'], 1).'</div>';
|
||||
}
|
||||
$str .= '</div>';
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LoadEventsQuery
|
||||
{
|
||||
@@ -137,10 +136,6 @@ class LoadEventsQuery
|
||||
->orderBy('starttime', 'ASC')
|
||||
->get();
|
||||
|
||||
// dd($res);
|
||||
// dd($season, $league_id, $res);
|
||||
Log::info('season', $season);
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $value) {
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ class LoadEventsQueryAll
|
||||
$total_range = [];
|
||||
if ($similar_past_matches != 'none') {
|
||||
$team_id = 0;
|
||||
$ss_player_id = 0;
|
||||
$team_position = '';
|
||||
$exp_handicap = $match->exp_away - $match->exp_home;
|
||||
$exp_total = $match->exp_away + $match->exp_home;
|
||||
@@ -40,12 +41,6 @@ class LoadEventsQueryAll
|
||||
$total_range = [$exp_total - $accuracy, $exp_total + $accuracy];
|
||||
}
|
||||
|
||||
if ($similar_past_matches != 'none') {
|
||||
$team_position = '';
|
||||
$team_id = 0;
|
||||
$ss_player_id = 0;
|
||||
}
|
||||
|
||||
// dd($season);
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
|
||||
@@ -98,6 +93,8 @@ class LoadEventsQueryAll
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
// Log::debug('result', [$similar_past_matches, $home_id, $away_id, $team_id]);
|
||||
|
||||
return StatistikoEvent::with('home')->with('away')
|
||||
->where(function ($query) use ($league_id, $similar_past_matches) {
|
||||
switch ($similar_past_matches) {
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Charts\LoadEvents;
|
||||
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class LoadEventsQuerySPM
|
||||
{
|
||||
public static function load(array $filter, object $match)
|
||||
{
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
$season = $filter['season'];
|
||||
$seasonmode = $filter['seasonmode'];
|
||||
$season_or_date = $filter['season_or_date'];
|
||||
$accuracy = (float) $filter['accuracy'] ?? 0.5;
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
$end = $filter['end_date'] ?? 0;
|
||||
if ($season_or_date == 'season') {
|
||||
$start = 0;
|
||||
$end = 0;
|
||||
}
|
||||
$ss_player_id = (int) $filter['ss_player_id'] ?? 0;
|
||||
$player_on_field = $filter['player_on_field'] ?? 'all';
|
||||
$similar_past_matches = $filter['similar_past_matches'];
|
||||
$team_position = $filter['team_position'];
|
||||
$home_id = $match->home_id;
|
||||
$away_id = $match->away_id;
|
||||
|
||||
$handicap_range = [];
|
||||
$total_range = [];
|
||||
if ($similar_past_matches != 'none') {
|
||||
$team_id = 0;
|
||||
$ss_player_id = 0;
|
||||
$team_position = '';
|
||||
$exp_handicap = $match->exp_away - $match->exp_home;
|
||||
$exp_total = $match->exp_away + $match->exp_home;
|
||||
$handicap_range = [$exp_handicap - $accuracy, $exp_handicap + $accuracy];
|
||||
$total_range = [$exp_total - $accuracy, $exp_total + $accuracy];
|
||||
}
|
||||
|
||||
// dd($season);
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
|
||||
/**
|
||||
* IF WITH PLAYER
|
||||
*/
|
||||
$matches_played = [];
|
||||
|
||||
if ($ss_player_id) {
|
||||
$matches_season = StatistikoEvent::whereIn('season', $season)
|
||||
->where(function ($query) use ($team_id, $team_position) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', '=', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', '=', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
$matches_played = StatistikoPlayer::query()
|
||||
->whereIn('match_id', $matches_season)
|
||||
->where('ss_player_id', $ss_player_id)
|
||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
// 'substituted' => 'Substituted',
|
||||
// 'notplayed' => 'Not Played',
|
||||
switch ($player_on_field) {
|
||||
case 'all':
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
case 'lineup':
|
||||
return $query->where('lineup', 'T')->where('minutes_played', '>', 0);
|
||||
case 'substituted':
|
||||
return $query->where('lineup', 'P')->where('minutes_played', '>', 0);
|
||||
default:
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
}
|
||||
})
|
||||
->pluck('match_id')->toArray();
|
||||
|
||||
if (! $matches_played) {
|
||||
$matches_played[] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// dd($handicap_range, $total_range);
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
// Log::debug('result', [$similar_past_matches, $home_id, $away_id, $team_id]);
|
||||
|
||||
return StatistikoEvent::with('home')->with('away')
|
||||
->where(function ($query) use ($league_id, $similar_past_matches) {
|
||||
switch ($similar_past_matches) {
|
||||
case 'none':
|
||||
case 'league':
|
||||
return $query->where('league_id', $league_id);
|
||||
}
|
||||
})
|
||||
->where(function ($query) use ($team_id, $home_id, $away_id, $similar_past_matches) {
|
||||
if ($similar_past_matches == 'none') {
|
||||
if ($team_id) {
|
||||
return $query->orWhere('home_id', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
} else {
|
||||
return $query->whereIn('home_id', [$home_id, $away_id])->orWhereIn('away_id', [$home_id, $away_id]);
|
||||
}
|
||||
}
|
||||
})
|
||||
->when($matches_played, function ($query) use ($matches_played, $player_on_field) {
|
||||
if ($player_on_field == 'notplayed') {
|
||||
return $query->whereNotIn('match_id', $matches_played);
|
||||
} else {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
}
|
||||
})
|
||||
->when($handicap_range, function ($query) use ($handicap_range) {
|
||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
})->when($total_range, function ($query) use ($total_range) {
|
||||
return $query->whereBetween('exp_total', $total_range);
|
||||
})
|
||||
->when($start, function ($query) use ($start) {
|
||||
return $query->whereDate('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->whereDate('starttime', '<=', $end);
|
||||
})
|
||||
->when($season, function ($query) use ($season, $season_or_date, $similar_past_matches) {
|
||||
if ($similar_past_matches == 'none' && $season_or_date == 'season') {
|
||||
return $query->whereIn('season', $season);
|
||||
}
|
||||
})
|
||||
->orderBy('starttime', 'ASC')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SimpleMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
// Optionale Daten, die an das Blade-Template übergeben werden
|
||||
public string $title;
|
||||
public string $body;
|
||||
|
||||
public function __construct(string $title, string $body)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Dies ist eine einfache Test-Mail',
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mail.simple', // Pfad zum Blade-Template
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Mail\SimpleMail;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class CloudflareSolverService
|
||||
{
|
||||
protected string $solverUrl = 'http://192.168.178.187:8191/v1';
|
||||
protected string $solverUrl = 'http://flaresolverr:8191/v1';
|
||||
|
||||
/**
|
||||
* Holt die Daten und gibt das extrahierte JSON als PHP-Array zurück.
|
||||
@@ -15,11 +17,8 @@ class CloudflareSolverService
|
||||
*/
|
||||
public function getJsonFromUrl(string $targetUrl): ?array
|
||||
{
|
||||
/**
|
||||
* set in .env
|
||||
* FLARESOLVERR_IP_DOCKER="http://192.168.178.187:8191/v1"
|
||||
*/
|
||||
$this->solverUrl = env('FLARESOLVERR_IP_DOCKER', 'http://192.168.178.187:8191/v1');
|
||||
|
||||
$this->solverUrl = config('services.flaresolverr.id_docker');
|
||||
|
||||
try {
|
||||
$response = Http::withHeaders([
|
||||
@@ -31,16 +30,17 @@ class CloudflareSolverService
|
||||
]);
|
||||
|
||||
if ($response->failed()) {
|
||||
Log::error('FlareSolverr Verbindungsfehler. Status: ' . $response->status());
|
||||
// Log::error('FlareSolverr Verbindungsfehler. Status: ' . $response->status());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = $response->json();
|
||||
|
||||
$tmp = json_encode($data);
|
||||
// if (strpos($tmp, "reason") !== false && strpos($tmp, 403) !== false)
|
||||
// dd($data);
|
||||
if (strpos($data['solution']['response'], '"code": 403, "reason": "challenge"') !== false) {
|
||||
Mail::to('hermann.telser@gmail.com')->send(new SimpleMail('STATISTIKO', 'Error 403 challenge'));
|
||||
dd('challenge');
|
||||
}
|
||||
|
||||
if (isset($data['status']) && $data['status'] === 'ok') {
|
||||
$htmlContent = $data['solution']['response'];
|
||||
@@ -55,18 +55,19 @@ class CloudflareSolverService
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
Log::error('Extrahiertes Textfragment ist kein gültiges JSON.');
|
||||
// Log::error('Extrahiertes Textfragment ist kein gültiges JSON.');
|
||||
} else {
|
||||
Log::error('Kein JSON-Muster { ... } im HTML gefunden.');
|
||||
// Log::error('Kein JSON-Muster { ... } im HTML gefunden.');
|
||||
}
|
||||
} else {
|
||||
Log::error('FlareSolverr konnte die Seite nicht umgehen: ' . json_encode($data));
|
||||
// Log::error('FlareSolverr konnte die Seite nicht umgehen: '.json_encode($data));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('PHP Exception im CloudflareSolverService: ' . $e->getMessage());
|
||||
// Log::error('PHP Exception im CloudflareSolverService: '.$e->getMessage());
|
||||
}
|
||||
|
||||
// Falls irgendwo ein Fehler auftrat, geben wir null zurück
|
||||
return null;
|
||||
Notice::note('ERROR connecting FLARESOLVERR_IP_DOCKER', 'br', 1);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
trait GrapperEvent
|
||||
trait GrappingEvent
|
||||
{
|
||||
protected function get_event(string $day, array $tournament)
|
||||
{
|
||||
@@ -22,12 +22,10 @@ trait GrapperEvent
|
||||
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";
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note($url, 'b');
|
||||
Notice::note($url, 'p');
|
||||
}
|
||||
|
||||
$this->sleep(1);
|
||||
@@ -149,6 +147,10 @@ trait GrapperEvent
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($this->debug) {
|
||||
Notice::note($day . ' - ' . $tournament['tournament']['name'] . " no events", 'y');
|
||||
}
|
||||
}
|
||||
|
||||
SofaScoreTaskDay::updateOrCreate([
|
||||
@@ -215,159 +215,6 @@ trait GrappingHelper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of grap_tournaments_for_day
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function grap_tournaments_for_day(string $day)
|
||||
{
|
||||
$tournaments_counter = 0;
|
||||
$sport_id = 1;
|
||||
|
||||
$has = SofaScoreDayTournament::where('day', $day)->first();
|
||||
|
||||
$slug = 'football';
|
||||
|
||||
if (! $this->force && $has) {
|
||||
if ($this->debug) {
|
||||
Notice::note("tournaments $day for " . strtoupper($slug) . ' allready grapped', 'bb');
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note("grappig tournaments for $day", 'bb');
|
||||
}
|
||||
|
||||
$page = 1;
|
||||
|
||||
while ($page) {
|
||||
// $data = $this->curl($url);
|
||||
|
||||
$this->sleep();
|
||||
|
||||
$url = $this->base_url . "api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
|
||||
|
||||
$cloudflareService = new CloudflareSolverService;
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
if ($data['hasNextPage']) {
|
||||
$page++;
|
||||
} else {
|
||||
$page = false;
|
||||
}
|
||||
|
||||
foreach ($data['scheduled'] as $row) {
|
||||
|
||||
if (isset($row['tournament']['uniqueTournament'])) {
|
||||
$tournament = $row['tournament']['uniqueTournament'];
|
||||
} else {
|
||||
$tournament = $row['tournament'];
|
||||
}
|
||||
|
||||
$category = $tournament['category'];
|
||||
|
||||
if ($sport_id == 5) {
|
||||
$country_id = 470;
|
||||
} else {
|
||||
|
||||
/**
|
||||
* CATEGORY
|
||||
*/
|
||||
$find = [
|
||||
'Amateur',
|
||||
'Bosnia & Herzegovina',
|
||||
'Czechia',
|
||||
'DR Congo',
|
||||
'Netherlands',
|
||||
'North & Central America',
|
||||
'Bonaire',
|
||||
'Sao Tome and Principe',
|
||||
'Cape Verde',
|
||||
'Macao',
|
||||
'Saint Kitts and Nevis',
|
||||
'Eswatini',
|
||||
'Timor Leste',
|
||||
'Laos',
|
||||
'Congo Republic',
|
||||
|
||||
];
|
||||
$replace = [
|
||||
'',
|
||||
'Bosnia Herzegovina',
|
||||
'Czech Republic',
|
||||
'Congo DR',
|
||||
'Holland',
|
||||
'North America',
|
||||
'Bonaire, Sint Eustatius and Saba',
|
||||
'Sao Tome e Principe',
|
||||
'Cape Verde Islands',
|
||||
'Macau',
|
||||
'St. Kitts and Nevis',
|
||||
'Swaziland',
|
||||
'East Timor',
|
||||
'Lao Peoples\'s Democratic Republic',
|
||||
'Congo DR',
|
||||
];
|
||||
$country_id = Country::where('name', trim(str_replace($find, $replace, $category['name'])))->value('id');
|
||||
}
|
||||
|
||||
if (! $country_id) {
|
||||
// platzhalter fix later sofa_score_categories => txodds countries
|
||||
// CATEGORY find <-> replace
|
||||
// Log::channel('sofascore')->info($tournament);
|
||||
|
||||
$sofa_score_category_id = 10000000;
|
||||
} else {
|
||||
$call = SofaScoreCategory::updateOrCreate([
|
||||
'id' => (int) $category['id'],
|
||||
'country_id' => (int) $country_id,
|
||||
'slug' => $category['slug'],
|
||||
], [
|
||||
'name' => $category['name'],
|
||||
]);
|
||||
|
||||
$sofa_score_category_id = $call->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* TOURNAMENT
|
||||
*/
|
||||
SofaScoreTournament::updateOrCreate([
|
||||
'sport_id' => (int) $sport_id,
|
||||
'tournament_id' => (int) $tournament['id'],
|
||||
'sofa_score_category_id' => (int) $sofa_score_category_id,
|
||||
], [
|
||||
'name' => $tournament['name'],
|
||||
'slug' => $tournament['slug'],
|
||||
]);
|
||||
$tournaments_counter++;
|
||||
|
||||
// if ($debug) {
|
||||
// Notice::note('tournament: ' . $tournament['name'], 'p');
|
||||
// }
|
||||
|
||||
/**
|
||||
* DAY TOURNAMENT
|
||||
*/
|
||||
SofaScoreDayTournament::updateOrCreate([
|
||||
'tournament_id' => (int) $tournament['id'],
|
||||
'sport_id' => (int) $sport_id,
|
||||
'day' => $day,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note("tournaments: $tournaments_counter", 'p');
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->debug) {
|
||||
Notice::note('days tournament done', 'g');
|
||||
}
|
||||
}
|
||||
|
||||
protected function get_tree(string $dir, &$results = [])
|
||||
{
|
||||
$files = scandir($dir);
|
||||
|
||||
@@ -2,19 +2,22 @@
|
||||
|
||||
namespace App\Traits\Sofascore;
|
||||
|
||||
use App\Mail\SimpleMail;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
use function Laravel\Prompts\select;
|
||||
use function Laravel\Prompts\text;
|
||||
|
||||
trait GrapSofascore
|
||||
trait GrappingSofascore
|
||||
{
|
||||
use GrapperEvent;
|
||||
use GrappingEvent;
|
||||
use GrappingHelper;
|
||||
use GrappingMail;
|
||||
use GrappingToExcel;
|
||||
use GrappingTournaments;
|
||||
|
||||
protected int $debug;
|
||||
|
||||
@@ -232,7 +235,7 @@ trait GrapSofascore
|
||||
|
||||
if (in_array($day, $day_done)) {
|
||||
if ($this->debug) {
|
||||
Notice::note("$day already in folder", 'br');
|
||||
Notice::note("$day Events allready grapped", 'br');
|
||||
}
|
||||
} else {
|
||||
$this->grap_tournaments_for_day($day);
|
||||
@@ -246,6 +249,8 @@ trait GrapSofascore
|
||||
$this->import_to_excel($folder);
|
||||
|
||||
Notice::note('Done', 'g');
|
||||
|
||||
Mail::to('hermann.telser@gmail.com')->send(new SimpleMail('STATISTIKO', 'Grapping compleated'));
|
||||
}
|
||||
|
||||
protected function days_done(): array
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\Sofascore;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\SofaScoreCategory;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Services\CloudflareSolverService;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
trait GrappingTournaments
|
||||
{
|
||||
/**
|
||||
* Summary of grap_tournaments_for_day
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function grap_tournaments_for_day(string $day)
|
||||
{
|
||||
$sport_id = 1;
|
||||
|
||||
$has = SofaScoreDayTournament::where('day', $day)->first();
|
||||
|
||||
$slug = 'football';
|
||||
|
||||
if (! $this->force && $has) {
|
||||
if ($this->debug) {
|
||||
Notice::note("$day Tournaments allready grapped", 'bb');
|
||||
}
|
||||
} else {
|
||||
|
||||
$page = 1;
|
||||
$tournaments_counter = 0;
|
||||
|
||||
while ($page) {
|
||||
// $data = $this->curl($url);
|
||||
|
||||
$this->sleep();
|
||||
|
||||
$url = $this->base_url . "api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
|
||||
|
||||
$cloudflareService = new CloudflareSolverService;
|
||||
|
||||
$data = $cloudflareService->getJsonFromUrl($url);
|
||||
|
||||
if ($data['hasNextPage']) {
|
||||
$page++;
|
||||
} else {
|
||||
$page = false;
|
||||
}
|
||||
|
||||
foreach ($data['scheduled'] as $row) {
|
||||
|
||||
if (isset($row['tournament']['uniqueTournament'])) {
|
||||
$tournament = $row['tournament']['uniqueTournament'];
|
||||
} else {
|
||||
$tournament = $row['tournament'];
|
||||
}
|
||||
|
||||
$category = $tournament['category'];
|
||||
|
||||
if ($sport_id == 5) {
|
||||
$country_id = 470;
|
||||
} else {
|
||||
|
||||
/**
|
||||
* CATEGORY
|
||||
*/
|
||||
$find = [
|
||||
'Amateur',
|
||||
'Bosnia & Herzegovina',
|
||||
'Czechia',
|
||||
'DR Congo',
|
||||
'Netherlands',
|
||||
'North & Central America',
|
||||
'Bonaire',
|
||||
'Sao Tome and Principe',
|
||||
'Cape Verde',
|
||||
'Macao',
|
||||
'Saint Kitts and Nevis',
|
||||
'Eswatini',
|
||||
'Timor Leste',
|
||||
'Laos',
|
||||
'Congo Republic',
|
||||
|
||||
];
|
||||
$replace = [
|
||||
'',
|
||||
'Bosnia Herzegovina',
|
||||
'Czech Republic',
|
||||
'Congo DR',
|
||||
'Holland',
|
||||
'North America',
|
||||
'Bonaire, Sint Eustatius and Saba',
|
||||
'Sao Tome e Principe',
|
||||
'Cape Verde Islands',
|
||||
'Macau',
|
||||
'St. Kitts and Nevis',
|
||||
'Swaziland',
|
||||
'East Timor',
|
||||
'Lao Peoples\'s Democratic Republic',
|
||||
'Congo DR',
|
||||
];
|
||||
$country_id = Country::where('name', trim(str_replace($find, $replace, $category['name'])))->value('id');
|
||||
}
|
||||
|
||||
if (! $country_id) {
|
||||
// platzhalter fix later sofa_score_categories => txodds countries
|
||||
// CATEGORY find <-> replace
|
||||
// Log::channel('sofascore')->info($tournament);
|
||||
|
||||
$sofa_score_category_id = 10000000;
|
||||
} else {
|
||||
$call = SofaScoreCategory::updateOrCreate([
|
||||
'id' => (int) $category['id'],
|
||||
'country_id' => (int) $country_id,
|
||||
'slug' => $category['slug'],
|
||||
], [
|
||||
'name' => $category['name'],
|
||||
]);
|
||||
|
||||
$sofa_score_category_id = $call->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* TOURNAMENT
|
||||
*/
|
||||
SofaScoreTournament::updateOrCreate([
|
||||
'sport_id' => (int) $sport_id,
|
||||
'tournament_id' => (int) $tournament['id'],
|
||||
'sofa_score_category_id' => (int) $sofa_score_category_id,
|
||||
], [
|
||||
'name' => $tournament['name'],
|
||||
'slug' => $tournament['slug'],
|
||||
]);
|
||||
$tournaments_counter++;
|
||||
|
||||
// if ($debug) {
|
||||
// Notice::note('tournament: ' . $tournament['name'], 'p');
|
||||
// }
|
||||
|
||||
/**
|
||||
* DAY TOURNAMENT
|
||||
*/
|
||||
SofaScoreDayTournament::updateOrCreate([
|
||||
'tournament_id' => (int) $tournament['id'],
|
||||
'sport_id' => (int) $sport_id,
|
||||
'day' => $day,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note("Tournaments: $tournaments_counter", 'p');
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note("$day Tournaments loaded", 'bb');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+218
-211
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -65,7 +65,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => env('APP_TIMEZONE', 'UTC'),
|
||||
'timezone' => env('APP_TIMEZONE', 'Europe/Berlin'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
+4
-1
@@ -14,6 +14,8 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
|
||||
'postmark' => [
|
||||
'token' => env('POSTMARK_TOKEN'),
|
||||
],
|
||||
@@ -36,7 +38,8 @@ return [
|
||||
],
|
||||
|
||||
'flaresolverr' => [
|
||||
'url' => env('FLARESOLVERR_URL', '192.168.178'),
|
||||
'url' => env('FLARESOLVERR_URL'),
|
||||
'id_docker' => env('FLARESOLVERR_IP_DOCKER'),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,80 @@
|
||||
services:
|
||||
# 1. PHP Laravel App (Nutzt jetzt das lokale Dockerfile aus dem letzten Schritt)
|
||||
laravel-app:
|
||||
build: /volume2/laravel-stack/
|
||||
container_name: laravel-app
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- /volume2/laravel-stack/app:/var/www/html
|
||||
networks:
|
||||
- laravel-network
|
||||
|
||||
# 2. Der Laravel-Scheduler
|
||||
laravel-scheduler:
|
||||
build: /volume2/laravel-stack/
|
||||
container_name: laravel-scheduler
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- /volume2/laravel-stack/app:/var/www/html
|
||||
command: php /var/www/html/artisan schedule:work
|
||||
depends_on:
|
||||
- laravel-app
|
||||
networks:
|
||||
- laravel-network
|
||||
|
||||
# 3. Caddy Webserver
|
||||
caddy:
|
||||
image: caddy:2-alpine
|
||||
container_name: caddy-server
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:80"
|
||||
- "8443:443"
|
||||
volumes:
|
||||
- /volume2/laravel-stack/caddy/Caddyfile:/etc/caddy/Caddyfile
|
||||
- caddy_data:/data # Verwaltet durch Docker (Sicher vor Rechteregeln)
|
||||
- /volume2/laravel-stack/app:/var/www/html
|
||||
depends_on:
|
||||
- laravel-app
|
||||
networks:
|
||||
- laravel-network
|
||||
|
||||
# 4. MariaDB Datenbank (Port 3306 offen für Ihren Import!)
|
||||
mariadb:
|
||||
image: mariadb:11-noble
|
||||
container_name: mariadb-db
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: salam
|
||||
MYSQL_DATABASE: nuhodds_fi4
|
||||
MYSQL_USER: root
|
||||
MYSQL_PASSWORD: salam
|
||||
volumes:
|
||||
- mariadb_data:/var/lib/mysql # Verwaltet durch Docker (Sicher vor Rechteregeln)
|
||||
networks:
|
||||
- laravel-network
|
||||
|
||||
# 5. MongoDB Datenbank
|
||||
mongodb:
|
||||
image: mongo:latest
|
||||
container_name: mongodb-db
|
||||
restart: unless-stopped
|
||||
user: "0:0"
|
||||
ports:
|
||||
- "27017:27017"
|
||||
volumes:
|
||||
- mongo_nopass_data:/data/db # Verwaltet durch Docker (Sicher vor Rechteregeln)
|
||||
networks:
|
||||
- laravel-network
|
||||
|
||||
networks:
|
||||
laravel-network:
|
||||
driver: bridge
|
||||
|
||||
# Hier weisen wir Docker an, die Ordner im geschützten Docker-Speicher zu erstellen
|
||||
volumes:
|
||||
mariadb_data:
|
||||
mongo_nopass_data:
|
||||
caddy_data:
|
||||
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Statistiko Info Mail</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>{{ $title }}</h1>
|
||||
<p>{{ $body }}</p>
|
||||
<p>All is good!</p>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -9,3 +9,4 @@ Artisan::command('inspire', function () {
|
||||
})->purpose('Display an inspiring quote');
|
||||
|
||||
Schedule::command('model:prune')->hourly();
|
||||
Schedule::command('grp:daily')->dailyAt('08:00');
|
||||
+2
-2
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Livewire\OpenExternalPage;
|
||||
use App\Mail\SimpleMail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
@@ -20,5 +22,3 @@ use Illuminate\Support\Facades\Route;
|
||||
Route::controller(OpenExternalPage::class)->group(function () {
|
||||
Route::get('/txodds_odds/{sportid}/{txoddsid}', 'txodds_odds')->name('txodds_odds');
|
||||
});
|
||||
|
||||
// Route::middleware('auth:sanctum')->group(function () {});
|
||||
@@ -1 +0,0 @@
|
||||
supervisorctl update
|
||||
Reference in new issue
Block a user