From 987d096928a63b54d9d6657d7e3ab60b3c1d7f6d Mon Sep 17 00:00:00 2001 From: salam Date: Tue, 14 Jul 2026 12:56:24 +0200 Subject: [PATCH] wip STA --- _WORK.md | 2 +- .../Commands/Grapper/Sofascore/CreateZip.php | 11 +- .../Tables/SofaScoreTournamentsTable.php | 251 +++++++++--------- .../Resources/Events/EventResource.php | 2 +- app/Providers/Filament/AdminPanelProvider.php | 17 +- app/Utilities/ZipFolder.php | 7 +- grapper.sh | 4 +- public/logo/sta.svg | 9 + 8 files changed, 149 insertions(+), 154 deletions(-) create mode 100644 public/logo/sta.svg diff --git a/_WORK.md b/_WORK.md index 6d2ad6a4..f8b3b78e 100644 --- a/_WORK.md +++ b/_WORK.md @@ -1,3 +1,3 @@ 1) Find double 2) Download all data -3) fix grapper \ No newline at end of file +3) fix grapper make only in tournament on/off, in Task only Dates \ No newline at end of file diff --git a/app/Console/Commands/Grapper/Sofascore/CreateZip.php b/app/Console/Commands/Grapper/Sofascore/CreateZip.php index b53d1ccb..d85bd5b2 100644 --- a/app/Console/Commands/Grapper/Sofascore/CreateZip.php +++ b/app/Console/Commands/Grapper/Sofascore/CreateZip.php @@ -2,7 +2,7 @@ namespace App\Console\Commands\Grapper\Sofascore; -use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays; +use App\Console\Commands\Grapper\Sofascore; use App\Console\Commands\Nuh; use App\Utilities\Notice; use App\Utilities\ZipFolder; @@ -13,14 +13,7 @@ class CreateZip { $debug = Nuh::$options['d'] ?? 0; - $days = LoadDays::load(); - - foreach ($days as $d) { - - $day = $d['day']; - - ZipFolder::create($day); - } + ZipFolder::create(Sofascore::$storage); if ($debug) { Notice::note('zips created', 'bb'); diff --git a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php index 5d734214..e9c0b04a 100644 --- a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php @@ -27,82 +27,73 @@ class SofaScoreTournamentsTable { return $table ->columns([ - IconColumn::make('sport.icon') - ->label('') - ->grow(false) - ->width(30) - ->color(fn ($record) => $record->sport->color) - ->icon(fn ($record) => $record->sport->icon) - ->size(IconSize::Medium) - ->tooltip(fn ($record) => $record->id) - ->visibleFrom('lg'), - TextColumn::make('tournament_id')->sortable()->searchable(), - TextColumn::make('sport.name'), - TextColumn::make('sofascore_category.name') - ->icon(fn ($record) => $record->sofascore_category->country->icon), - TextColumn::make('name')->searchable()->sortable(), - // ToggleColumn::make('enabled')->label('Enable'), - ToggleColumn::make('disabled')->label('Disable'), + IconColumn::make('sport.icon') + ->label('') + ->grow(false) + ->width(30) + ->color(fn($record) => $record->sport->color) + ->icon(fn($record) => $record->sport->icon) + ->size(IconSize::Medium) + ->tooltip(fn($record) => $record->id) + ->visibleFrom('lg'), + TextColumn::make('tournament_id')->sortable()->searchable(), + TextColumn::make('sport.name'), + TextColumn::make('sofascore_category.name') + ->icon(fn($record) => $record->sofascore_category->country->icon), + TextColumn::make('name')->searchable()->sortable(), + ToggleColumn::make('enabled')->label('Enable'), + ToggleColumn::make('disabled')->label('Hidden'), ]) ->filters([ - Filter::make('filters') - ->columns(7)->columnSpan(7) - ->schema([ - Select::make('sport_id') - ->default(1) - ->selectablePlaceholder(false) - ->label('Sport') - ->options(Sport::where('is_active', 1)->pluck('name', 'id')) - ->afterStateUpdated(function (callable $set) { - $set('sofa_score_categorie_id', null); - }) - ->live(), - Select::make('sofa_score_categorie_id') - ->searchable() - ->multiple() - ->columnSpan(2) - ->label('Categorie') - ->options(function (Get $get) { - $res = SofaScoreTournament::where('sport_id', $get('sport_id')) - ->groupBy('sofa_score_categorie_id') - ->pluck('sofa_score_categorie_id') - ->toArray(); + Filter::make('filters') + ->columns(7)->columnSpan(7) + ->schema([ + Select::make('sport_id') + ->default(1) + ->selectablePlaceholder(false) + ->label('Sport') + ->options(Sport::where('is_active', 1)->pluck('name', 'id')) + ->afterStateUpdated(function (callable $set) { + $set('sofa_score_categorie_id', null); + }) + ->live(), + Select::make('sofa_score_categorie_id') + ->searchable() + ->multiple() + ->columnSpan(2) + ->label('Categorie') + ->options(function (Get $get) { + $res = SofaScoreTournament::where('sport_id', $get('sport_id')) + ->groupBy('sofa_score_categorie_id') + ->pluck('sofa_score_categorie_id') + ->toArray(); - return SofaScoreCategorie::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id'); - }) - ->live(), - // ToggleButtons::make('filter-grapping') - // ->inline() - // ->columnSpan(2) - // ->default('active') - // ->options([ - // 'all' => 'All', - // 'active' => 'Active', - // 'disabled' => 'Disabled', - // ]), - ToggleButtons::make('filter-disabled') - ->inline() - ->columnSpan(2) - ->default('active') - ->options([ - 'all' => 'All', - 'active' => 'Active', - 'hidden' => 'Hidden', - ]), - ]) - ->query(function (Builder $query, array $data): Builder { - return $query->when( - $data['sport_id'], - fn (Builder $query, $sport_id) => $query->where('sport_id', $sport_id) - )->when( - $data['sofa_score_categorie_id'], - function (Builder $query, $sofa_score_categorie_id) { - if (is_array($sofa_score_categorie_id)) { - $query->whereIn('sofa_score_categorie_id', $sofa_score_categorie_id); - } else { - $query->where('sofa_score_categorie_id', $sofa_score_categorie_id); - } + return SofaScoreCategorie::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id'); + }) + ->live(), + ToggleButtons::make('filter-disabled') + ->inline() + ->columnSpan(2) + ->default('active') + ->options([ + 'all' => 'All', + 'enabled' => 'Enabled', + 'hidden' => 'Hidden', + ]), + ]) + ->query(function (Builder $query, array $data): Builder { + return $query->when( + $data['sport_id'], + fn(Builder $query, $sport_id) => $query->where('sport_id', $sport_id) + )->when( + $data['sofa_score_categorie_id'], + function (Builder $query, $sofa_score_categorie_id) { + if (is_array($sofa_score_categorie_id)) { + $query->whereIn('sofa_score_categorie_id', $sofa_score_categorie_id); + } else { + $query->where('sofa_score_categorie_id', $sofa_score_categorie_id); } + } // )->when( // $data['filter-grapping'], // function (Builder $query, $filtergrapping) { @@ -115,71 +106,71 @@ class SofaScoreTournamentsTable // break; // } // } - )->when( - $data['filter-disabled'], - function (Builder $query, $filterdisabled) { - switch ($filterdisabled) { - case 'active': - $query->where('disabled', 0); - break; - case 'hidden': - $query->where('disabled', 1); - break; - } + )->when( + $data['filter-disabled'], + function (Builder $query, $filterdisabled) { + switch ($filterdisabled) { + case 'enabled': + $query->where('enabled', 1); + break; + case 'hidden': + $query->where('disabled', 1); + break; } - ); - }), + } + ); + }), ], layout: FiltersLayout::AboveContent) ->deferFilters(false) ->toolbarActions([ BulkActionGroup::make([ - BulkAction::make('Enable') - ->icon('phosphor-toggle-right-fill') - ->color('primary') - ->action(function (Collection $records): void { - foreach ($records as $record) { - SofaScoreTournament::where('id', '=', $record->id) - ->update( - ['enabled' => 1] - ); - } - }), - BulkAction::make('Disable') - ->icon('phosphor-toggle-left-fill') - ->color('gray') - ->action(function (Collection $records): void { - foreach ($records as $record) { - SofaScoreTournament::where('id', '=', $record->id) - ->update( - ['enabled' => 0] - ); - } - }), + BulkAction::make('Enable selected') + ->icon('phosphor-toggle-right-fill') + ->color('primary') + ->action(function (Collection $records): void { + foreach ($records as $record) { + SofaScoreTournament::where('id', '=', $record->id) + ->update( + ['enabled' => 1] + ); + } + }), + BulkAction::make('Disable selected') + ->icon('phosphor-toggle-left-fill') + ->color('gray') + ->action(function (Collection $records): void { + foreach ($records as $record) { + SofaScoreTournament::where('id', '=', $record->id) + ->update( + ['enabled' => 0] + ); + } + }), ])->label('Grapping'), BulkActionGroup::make([ - BulkAction::make('Hide') - ->icon('phosphor-toggle-right-fill') - ->color('primary') - ->action(function (Collection $records): void { - foreach ($records as $record) { - SofaScoreTournament::where('id', '=', $record->id) - ->update( - ['disabled' => 1] - ); - } - }), - BulkAction::make('Show') - ->icon('phosphor-toggle-left-fill') - ->color('gray') - ->action(function (Collection $records): void { - foreach ($records as $record) { - SofaScoreTournament::where('id', '=', $record->id) - ->update( - ['disabled' => 0] - ); - } - }), - ])->label('Disabled'), + BulkAction::make('Hide selected') + ->icon('phosphor-toggle-right-fill') + ->color('primary') + ->action(function (Collection $records): void { + foreach ($records as $record) { + SofaScoreTournament::where('id', '=', $record->id) + ->update( + ['disabled' => 1] + ); + } + }), + BulkAction::make('Show selected') + ->icon('phosphor-toggle-left-fill') + ->color('gray') + ->action(function (Collection $records): void { + foreach ($records as $record) { + SofaScoreTournament::where('id', '=', $record->id) + ->update( + ['disabled' => 0] + ); + } + }), + ])->label('Hidden'), ]); } } diff --git a/app/Filament/Resources/Events/EventResource.php b/app/Filament/Resources/Events/EventResource.php index 8f99df95..18f6c68d 100644 --- a/app/Filament/Resources/Events/EventResource.php +++ b/app/Filament/Resources/Events/EventResource.php @@ -29,7 +29,7 @@ class EventResource extends Resource public static function getPluralModelLabel(): string { - return false; + return 'Monitor'; } public static function form(Schema $schema): Schema diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index b5422570..6f466825 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -50,9 +50,9 @@ class AdminPanelProvider extends PanelProvider ->columnMapping(false) ->exporter(BetfairExporter::class) ->label('Download Betfair') - ->visible(fn (): bool => auth()->user()->hasRole('download_betfair')) - ->fileName(fn (Export $export): string => 'betfair-odds-'.date('d.m.Y-H.i')."-{$export->getKey()}") - ->modifyQueryUsing(fn (Builder $query) => $query->whereHas('odds_3ways_bf') + ->visible(fn(): bool => auth()->user()->hasRole('download_betfair')) + ->fileName(fn(Export $export): string => 'betfair-odds-' . date('d.m.Y-H.i') . "-{$export->getKey()}") + ->modifyQueryUsing(fn(Builder $query) => $query->whereHas('odds_3ways_bf') ->whereHas('odds_totals_bf') ->where('sport_id', 1)) ->icon('phosphor-download'), @@ -69,9 +69,10 @@ class AdminPanelProvider extends PanelProvider ->default() ->globalSearch(false) ->globalSearchKeyBindings(['command+k', 'ctrl+k']) - ->brandLogo(asset('images/statistiko-d.svg')) - ->darkModeBrandLogo(asset('images/statistiko.svg')) - ->favicon(asset('images/nuh.svg')) + ->brandLogo(asset('logo/statistiko.svg')) + ->darkModeBrandLogo(asset('logo/statistiko-d.svg')) + ->favicon(asset('logo/sta.svg')) + ->brandName('') ->brandLogoHeight('2rem') ->unsavedChangesAlerts() ->topNavigation() @@ -92,8 +93,8 @@ class AdminPanelProvider extends PanelProvider ->sidebarCollapsibleOnDesktop(false) ->userMenuItems([ 'profile' => Action::make('profile') - ->label(fn () => Auth::user()->name) - ->url(fn (): string => EditProfilePage::getUrl()) + ->label(fn() => Auth::user()->name) + ->url(fn(): string => EditProfilePage::getUrl()) ->icon('phosphor-user-circle-fill'), ]) ->pages([ diff --git a/app/Utilities/ZipFolder.php b/app/Utilities/ZipFolder.php index f8d4c6f9..078ccfa8 100644 --- a/app/Utilities/ZipFolder.php +++ b/app/Utilities/ZipFolder.php @@ -9,13 +9,14 @@ use ZipArchive; class ZipFolder { - public static function create(string $day) + public static function create(string $path) { - $zipFilePath = Sofascore::$storage . '/' . $day . '.zip'; + // $zipFilePath = Sofascore::$storage . '/' . $day . '.zip'; - $path = Sofascore::$storage . '/' . $day; + // $path = Sofascore::$storage . '/' . $day; + $zipFilePath = $path . '/archive.zip'; $zip = new ZipArchive(); if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) { diff --git a/grapper.sh b/grapper.sh index df30ed8b..0cd2688b 100755 --- a/grapper.sh +++ b/grapper.sh @@ -41,8 +41,8 @@ case "$1" in # echo "\n⚽ TaskConfig end" # php artisan nuh --d --f 67 --fun=6 --task=$1 - # echo "\n⚽ CreateZip" - # php artisan nuh --d --f 67 --fun=7 --task=$1 + echo "\n⚽ CreateZip" + php artisan nuh --d --f 67 --fun=7 --task=$1 # echo "\n⚽ SendMail" # php artisan nuh --d --f 67 --fun=8 --task=$1 diff --git a/public/logo/sta.svg b/public/logo/sta.svg new file mode 100644 index 00000000..7cca4a73 --- /dev/null +++ b/public/logo/sta.svg @@ -0,0 +1,9 @@ + + + + + + + + +