This commit is contained in:
salam committed 2026-08-25 08:03:22 +02:00
1 parent d316d486b9
commit c6c5cdc1b1
21 files changed
+620 -34

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Actions;
use App\Models\SofaScoreCategory;
use App\Models\SofaScoreTournament;
use App\Models\StatisticFixtures;
class LoadSofaScoreCategory
{
public static function load()
{
$league_ids = StatisticFixtures::where('sport_id', 1)
->groupBy('league_id')
->pluck('league_id')->toArray();
$sofa_score_category_id = SofaScoreTournament::whereIn('tournament_id', $league_ids)->pluck('sofa_score_category_id')->toArray();
$sofa_score_category_id = array_unique($sofa_score_category_id);
return SofaScoreCategory::where('in_soccer', 1)->whereIn('id', $sofa_score_category_id)->orderBy('name')->pluck('name', 'id');
}
}
@@ -3,24 +3,15 @@
namespace App\Actions;
use App\Models\SofaScoreTournament;
use App\Models\StatisticFixtures;
class LoadStatisticFixturesLeaguesOptions
{
public static function load(int $sport_id)
public static function load(int|null $sofascore_category_id = 0)
{
$res = StatisticFixtures::where('sport_id', $sport_id)
->groupBy('league_id')
->pluck('league_id')->toArray();
// $res = StatisticFixtures::with('league')->where('league_id', $sofascore_category_id)
// ->groupBy('league_id')
// ->pluck('league_id')->toArray();
$cnt = SofaScoreTournament::with('sofascore_category')->whereIn('tournament_id', $res)->get();
$arr = [];
foreach ($cnt as $val) {
$arr[$val->tournament_id] = $val->sofascore_category->name . ' ' . $val->name;
}
asort($arr);
return $arr;
return SofaScoreTournament::where('enabled', 1)->where('sofa_score_category_id', $sofascore_category_id)->orderBy('name')->pluck('name', 'tournament_id');
}
}
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grap;
use App\Console\Commands\Grapper\Sofascore\Helper\ReadDir;
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
use App\Models\SofaScoreCategory;
use App\Models\SofaScoreRosa;
use App\Models\SofaScoreTask;
use App\Models\StatistikoEvent;
@@ -25,15 +26,22 @@ class SqlMover
// $files = ReadDir::get_tree($sofascore_data . $folder);
// dd($files);
$file = file_get_contents(__dir__ . '/SqlMover/grapped.txt');
$file = file_get_contents(__dir__ . '/SqlMover/country.txt');
$data = explode(PHP_EOL, $file);
$arr = [];
foreach ($data as $value) {
if (strpos($value, 'Grapped', 0) !== false) {
$arr[] = $value;
foreach ($data as $key => $value) {
if ($key) {
$row = explode(',', $value);
$country_id = $row[0];
$flag = $row[2];
$season_mode = $row[6];
SofaScoreCategory::where('country_id', $country_id)->update([
'season_mode' => $season_mode,
'flag' => $flag,
'in_soccer' => 1,
]);
}
}
Notice::note($arr, '', 1);
Notice::note('DONE', 'r', 1);
// Notice::note('StatistikoPlayer', 'b');
@@ -0,0 +1,51 @@
id,name,icon,iso2,iso3,cc,season_mode,is_country,disabled,created_at,updated_at
467,Argentina,flag-country-ar,AR,ARG,ARG,fullyear,1,0,NULL,2026-06-15 17:26:31
454,Australia,flag-country-au,AU,AUS,AUS,halfyear,1,0,NULL,2026-06-15 17:21:02
383,Austria,flag-country-at,AT,AUT,AUT,halfyear,1,0,NULL,2026-06-15 15:46:53
377,Belgium,flag-country-be,BE,BEL,BEL,halfyear,1,0,NULL,2026-06-15 17:21:02
409,Brazil,flag-country-br,BR,BRA,BRA,fullyear,1,0,NULL,2026-06-15 15:46:11
363,Bulgaria,flag-country-bg,BG,BGR,BUL,halfyear,1,0,NULL,2026-06-15 17:22:37
424,China,flag-country-cn,CN,CHN,CHN,fullyear,1,0,NULL,2026-06-15 15:44:40
389,Colombia,flag-country-co,CO,COL,COL,fullyear,1,0,NULL,2026-06-15 17:25:12
415,Croatia,flag-country-hr,HR,HRV,CRO,NULL,1,0,NULL,NULL
468,Czech Republic,flag-country-cz,CZ,CZE,CZE,NULL,1,0,NULL,2025-08-30 05:52:59
378,Denmark,flag-country-dk,DK,DNK,DEN,fullyear,1,0,NULL,2026-06-15 17:25:12
382,England,extra-england,NULL,ENG,ENG,NULL,1,0,2025-05-24 06:40:45,2025-05-24 06:40:45
678,Europe,flag-country-eu,NULL,NULL,REUROPE,NULL,0,0,2026-02-24 16:28:34,2026-02-24 16:30:36
381,European Cup,flag-country-eu,NULL,NULL,ECUP,halfyear,1,0,2025-08-30 04:45:37,2026-06-15 17:21:02
403,Finland,flag-country-fi,FI,FIN,FIN,fullyear,1,0,NULL,2026-06-15 17:25:12
408,France,flag-country-fr,FR,FRA,FRA,halfyear,1,0,NULL,2026-06-15 15:47:10
446,Germany,flag-country-de,DE,DEU,GER,halfyear,1,0,NULL,2026-06-15 15:47:39
394,Greece,flag-country-gr,GR,GRC,GRE,halfyear,1,0,NULL,2026-06-15 17:21:02
407,Holland,flag-country-nl,NL,NLD,DUT,halfyear,1,0,NULL,2026-06-15 17:21:02
412,Hungary,flag-country-hu,HU,HUN,HUN,halfyear,1,0,NULL,2026-06-15 17:21:02
373,Iceland,flag-country-is,IS,NULL,ICE,NULL,1,0,2025-08-30 04:45:33,2025-08-30 05:52:59
466,International,extra-caf,NULL,NULL,INT,NULL,1,0,2025-08-30 04:45:33,2025-08-30 05:52:59
543,International Cup,extra-world,NULL,NULL,ICUP,NULL,1,0,2025-08-30 04:45:36,2025-08-30 05:52:59
435,Ireland,flag-country-ie,IE,IRL,IRE,NULL,1,0,NULL,NULL
398,Italy,flag-country-it,IT,ITA,ITA,halfyear,1,0,NULL,2026-06-15 15:46:41
416,Japan,flag-country-jp,JP,JPN,JPN,fullyear,1,0,NULL,2026-06-15 15:44:23
406,Major League Soccer,NULL,NULL,NULL,MLS,fullyear,1,0,2025-08-30 04:45:33,2026-06-15 17:25:12
413,Mexico,flag-country-mx,MX,MEX,MEX,halfyear,1,0,NULL,2026-06-15 17:21:02
426,Northern Ireland,extra-nordirland,NULL,NIR,NIR,NULL,1,0,2025-05-24 06:40:45,2025-05-24 06:40:45
431,Norway,flag-country-no,NO,NOR,NOR,fullyear,1,0,NULL,2026-06-15 15:45:46
457,Peru,flag-country-pe,PE,PER,PER,NULL,1,0,NULL,2025-05-24 06:40:45
386,Poland,flag-country-pl,PL,POL,POL,halfyear,1,0,NULL,2026-06-15 17:21:02
418,Portugal,flag-country-pt,PT,PRT,POR,halfyear,1,0,NULL,2026-06-15 17:21:02
443,Romania,flag-country-ro,RO,ROU,ROM,halfyear,1,0,NULL,2026-06-15 17:21:02
368,Russia,flag-country-ru,RU,RUS,RUS,halfyear,1,0,NULL,2026-06-15 17:21:02
462,Saudi Arabia,flag-country-sa,SA,SAU,KSA,halfyear,1,0,NULL,2026-06-15 17:21:02
449,Scotland,extra-scotland,NULL,SCO,SCO,halfyear,1,0,2025-05-24 06:40:45,2026-06-15 17:21:02
428,Serbia,flag-country-rs,RS,SRB,SRB,halfyear,1,0,NULL,2026-06-15 17:21:02
391,Slovakia,flag-country-sk,SK,SVK,SVK,halfyear,1,0,NULL,2026-06-15 17:21:02
441,Slovenia,flag-country-si,SI,SVN,SLO,halfyear,1,0,NULL,2026-06-15 17:21:02
680,South America,extra-world,NULL,NULL,RSOAM,NULL,0,0,2026-02-24 16:28:34,2026-02-24 16:28:34
465,South America Cup,extra-world,NULL,NULL,SACUP,NULL,0,0,2026-02-24 16:28:34,2026-02-24 16:28:34
437,South Korea,flag-country-kr,KR,KOR,KOR,fullyear,1,0,NULL,2026-06-15 17:25:12
438,Spain,flag-country-es,ES,ESP,SPA,halfyear,1,0,NULL,2026-06-15 17:21:02
410,Sweden,flag-country-se,SE,SWE,SWE,fullyear,1,0,NULL,2026-06-15 15:45:31
451,Switzerland,flag-country-ch,CH,CHE,SWI,halfyear,1,0,NULL,2026-06-15 17:21:02
405,Turkey,flag-country-tr,TR,TUR,TUR,halfyear,1,0,NULL,2026-06-15 17:21:02
452,Ukraine,flag-country-ua,UA,UKR,UKR,halfyear,1,0,NULL,2026-06-15 17:21:02
1,World,extra-world,NULL,NULL,NULL,NULL,0,0,NULL,NULL
531,World Club Cup,NULL,NULL,NULL,WCLUB,NULL,0,0,2026-02-24 16:28:34,2026-02-24 16:28:34
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Pages;
use App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\SofaScoreCategoryResource;
use Filament\Resources\Pages\CreateRecord;
class CreateSofaScoreCategory extends CreateRecord
{
protected static string $resource = SofaScoreCategoryResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Pages;
use App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\SofaScoreCategoryResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditSofaScoreCategory extends EditRecord
{
protected static string $resource = SofaScoreCategoryResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Pages;
use App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\SofaScoreCategoryResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListSofaScoreCategories extends ListRecords
{
protected static string $resource = SofaScoreCategoryResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Schemas;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;
class SofaScoreCategoryForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('name')
->required(),
TextInput::make('slug')
->required(),
TextInput::make('season_mode')
->default(null),
TextInput::make('flag')
->default(null),
Toggle::make('in_soccer'),
TextInput::make('country_id')
->numeric()
->default(null),
]);
}
}
@@ -0,0 +1,53 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreCategories;
use App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Pages\CreateSofaScoreCategory;
use App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Pages\EditSofaScoreCategory;
use App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Pages\ListSofaScoreCategories;
use App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Schemas\SofaScoreCategoryForm;
use App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Tables\SofaScoreCategoriesTable;
use App\Filament\Clusters\StaticData\StaticDataCluster;
use App\Models\SofaScoreCategory;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use UnitEnum;
class SofaScoreCategoryResource extends Resource
{
protected static ?string $model = SofaScoreCategory::class;
protected static ?string $cluster = StaticDataCluster::class;
protected static ?int $navigationSort = 13;
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
protected static ?string $recordTitleAttribute = 'Countries';
protected static ?string $navigationLabel = 'Countries';
protected static ?string $modelLabel = 'Countries';
public static function form(Schema $schema): Schema
{
return SofaScoreCategoryForm::configure($schema);
}
public static function table(Table $table): Table
{
return SofaScoreCategoriesTable::configure($table);
}
public static function getPages(): array
{
return [
'index' => ListSofaScoreCategories::route('/'),
];
}
public static function getNavigationBadge(): ?string
{
return parent::getEloquentQuery()->count();
}
}
@@ -0,0 +1,49 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreCategories\Tables;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Support\Enums\IconSize;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
class SofaScoreCategoriesTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
IconColumn::make('flag')
->sortable()
->icon(function ($state): string {
return $state;
})->label('Flags'),
TextColumn::make('name')
->searchable(),
TextColumn::make('season_mode')
->sortable()
->badge()
->formatStateUsing(fn(string $state): string => strtoupper($state))
->color(fn(string $state): string => match ($state) {
'halfyear' => 'warning',
'fullyear' => 'success',
default => ''
}),
IconColumn::make('in_soccer')
->boolean(),
TextColumn::make('country_id')
->numeric()
->sortable(),
])
->filters([
TernaryFilter::make('in_soccer')->default(1)
])
->recordActions([
EditAction::make(),
]);
}
}
@@ -22,7 +22,7 @@ class SofaScoreRosasTable
->columns([
TextColumn::make('ss_team_id')->label('SSId')->badge()->width('1rem')
->sortable(),
TextColumn::make('country.name')->label('Country')
TextColumn::make('sofascore_category.name')->label('Country')
->sortable(),
TextColumn::make('tournament_rosa.tournament.name')->label('Tournament')
->sortable(),
@@ -41,7 +41,7 @@ class SofaScoreTournamentsTable
->searchable(),
TextColumn::make('sofascore_category.name')
->label('Country')
->icon(fn($record) => $record->sofascore_category->country->icon)
->icon(fn($record) => $record->sofascore_category->flag)
->sortable(),
TextColumn::make('name')->searchable()->sortable(),
ToggleColumn::make('enabled')
@@ -76,7 +76,7 @@ class SofaScoreTournamentsTable
return SofaScoreCategory::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
})
->live(),
Toggle::make('enabled')->label('In Statistiko'),
Toggle::make('enabled')->label('In Statistiko')->default(1),
])
->query(function (Builder $query, array $data): Builder {
return $query->when(
@@ -31,8 +31,14 @@ class StatisticFixturesTable
'3' => 'icon-basketball',
'5' => 'icon-tennisball',
}),
IconColumn::make('league.sofascore_category.flag')
->label('')
->icon(function ($state): string {
return $state;
}),
TextColumn::make('league.name')
->label('League')
->tooltip(fn($record) => $record->league_id)
->sortable()
->searchable()
->description(
@@ -38,15 +38,23 @@ class StatistikoEventsTable
->searchable(
query: fn($query, $search) => $query->orWhere('match_id', (int) $search)
),
IconColumn::make('league.sofascore_category.flag')
->label('')
->icon(function ($state): string {
return $state;
}),
TextColumn::make('league.name')
->tooltip(fn($record) => $record->league_id)
->sortable(
query: fn(Builder $query) => $query->orderBy('name')
)
->searchable(),
TextColumn::make('home.ss_team_name')->color('info')
->tooltip(fn($record) => $record->home_id)
->sortable()
->searchable(),
TextColumn::make('away.ss_team_name')->color('success')
->tooltip(fn($record) => $record->away_id)
->sortable()
->searchable(),
TextColumn::make('starttime')->dateTime('Y-m-d H:i')
+19 -3
View File
@@ -2,6 +2,7 @@
namespace App\Filament\Pages;
use App\Actions\LoadSofaScoreCategory;
use App\Actions\LoadStatisticFixturesLeaguesOptions;
use App\Actions\LoadStatisticFixturesMatchOptions;
use App\Filament\Pages\Selections\LoadPlayer;
@@ -15,7 +16,6 @@ use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Slider;
use Filament\Forms\Components\ToggleButtons;
use Filament\Pages\Dashboard as BaseDashboard;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Schemas\Components\Grid;
@@ -79,17 +79,33 @@ class Statistic extends BaseDashboard
Grid::make([
'default' => 1,
'sm' => 3,
'md' => 4,
'md' => 5,
])
->columnSpanFull()
->schema([
Select::make('sofascore_category_id')
->live()
->searchable()
->prefixIconColor(fn(Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger')
->prefixIcon('phosphor-globe-fill')
->hiddenLabel()
->options(fn() => LoadSofaScoreCategory::load())
->placeholder('Country')
->afterStateUpdated(function (callable $set) {
$set('league_id', null);
$set('match_id', null);
$set('team_id', null);
$set('ss_player_id', null);
$set('season', null);
}),
Select::make('league_id')
->live()
->searchable()
->prefixIconColor(fn(Get $get): string => $get('league_id') ? 'success' : 'danger')
->prefixIcon('phosphor-trophy-fill')
->hiddenLabel()
->options(fn() => LoadStatisticFixturesLeaguesOptions::load(1))
// ->options(fn(Get $get) => SofaScoreTournament::with('sofascore_category')->where('sofa_score_category_id', $get('sofascore_category_id'))->pluck('name', 'tournament_id'))
->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id')))
->placeholder('League')
->afterStateUpdated(function (callable $set, $state) {
$set('match_id', null);
+1 -1
View File
@@ -248,7 +248,7 @@ class LoadEvents
$dataset_away2[] = (int) $value['val_home'];
}
}
$n = max(count($dataset_home), count($dataset_home2));
$n = min(count($dataset_home), count($dataset_home2));
$f = array_first($labels);
$step = round($f / $n);
$labels = [];
@@ -86,7 +86,8 @@ class LoadEventsQuery
* STATTISTIC DATA
*/
$res = StatistikoEvent::with('home')->with('away')->where('league_id', 18)
// dd($league_id, $home_id, $away_id);
$res = StatistikoEvent::with('home')->with('away')
->where(function ($query) use ($league_id, $similar_past_matches) {
switch ($similar_past_matches) {
case 'none':
+3 -5
View File
@@ -10,11 +10,9 @@ class SofaScoreCategory extends Model
'id',
'name',
'slug',
'season_mode',
'flag',
'in_soccer',
'country_id',
];
public function country()
{
return $this->belongsTo(Country::class, 'country_id', 'id');
}
}
+5
View File
@@ -29,6 +29,11 @@ class SofaScoreRosa extends Model
return $this->belongsTo(Country::class);
}
public function sofascore_category()
{
return $this->belongsTo(SofaScoreCategory::class, 'country_id', 'country_id')->where('in_soccer', 1);
}
public function tournament_rosa()
{
return $this->belongsTo(SofaScoreRosaTournament::class, 'ss_team_id', 'ss_team_id');