wip
This commit is contained in:
1 parent
6d8d5f9136
commit
dc5480f91c
10 files changed
+185
-13
No files matched your search
@@ -12,6 +12,7 @@ use App\Models\SofaScoreTournament;
|
|||||||
use App\Models\Sport;
|
use App\Models\Sport;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class Tournament
|
class Tournament
|
||||||
{
|
{
|
||||||
@@ -51,19 +52,13 @@ class Tournament
|
|||||||
while ($page) {
|
while ($page) {
|
||||||
$url = Nuh::$options['base_url']."api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
$url = Nuh::$options['base_url']."api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
||||||
|
|
||||||
$rand = rand(1000000, 2000000);
|
$rand = rand(500000, 1000000);
|
||||||
if ($debug) {
|
if ($debug) {
|
||||||
Notice::note("Sleep $rand msec", 'y');
|
Notice::note("Sleep $rand msec", 'y');
|
||||||
}
|
}
|
||||||
usleep($rand);
|
usleep($rand);
|
||||||
|
|
||||||
// $data = Curl::load($url);
|
$data = Curl::load($url);
|
||||||
$ch = curl_init();
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
$response = curl_exec($ch);
|
|
||||||
$data = json_decode($response, true);
|
|
||||||
|
|
||||||
if ($data['hasNextPage']) {
|
if ($data['hasNextPage']) {
|
||||||
$page++;
|
$page++;
|
||||||
@@ -99,6 +94,12 @@ class Tournament
|
|||||||
'Sao Tome and Principe',
|
'Sao Tome and Principe',
|
||||||
'Cape Verde',
|
'Cape Verde',
|
||||||
'Macao',
|
'Macao',
|
||||||
|
'Saint Kitts and Nevis',
|
||||||
|
'Eswatini',
|
||||||
|
'Timor Leste',
|
||||||
|
'Laos',
|
||||||
|
'Congo Republic',
|
||||||
|
|
||||||
];
|
];
|
||||||
$replace = [
|
$replace = [
|
||||||
'',
|
'',
|
||||||
@@ -111,6 +112,11 @@ class Tournament
|
|||||||
'Sao Tome e Principe',
|
'Sao Tome e Principe',
|
||||||
'Cape Verde Islands',
|
'Cape Verde Islands',
|
||||||
'Macau',
|
'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');
|
$country_id = Country::where('name', trim(str_replace($find, $replace, $category['name'])))->value('id');
|
||||||
}
|
}
|
||||||
@@ -118,6 +124,8 @@ class Tournament
|
|||||||
if (! $country_id) {
|
if (! $country_id) {
|
||||||
// platzhalter fix later sofa_score_categories => txodds countries
|
// platzhalter fix later sofa_score_categories => txodds countries
|
||||||
// CATEGORY find <-> replace
|
// CATEGORY find <-> replace
|
||||||
|
Log::channel('sofascore')->info($tournament);
|
||||||
|
|
||||||
$sofa_score_categorie_id = 10000000;
|
$sofa_score_categorie_id = 10000000;
|
||||||
} else {
|
} else {
|
||||||
$call = SofaScoreCategorie::updateOrCreate([
|
$call = SofaScoreCategorie::updateOrCreate([
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateSofaScoreDay extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = SofaScoreDayResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditSofaScoreDay extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = SofaScoreDayResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
DeleteAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListSofaScoreDays extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = SofaScoreDayResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Schemas;
|
||||||
|
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class SofaScoreDayForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
//
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages\ListSofaScoreDays;
|
||||||
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Schemas\SofaScoreDayForm;
|
||||||
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Tables\SofaScoreDaysTable;
|
||||||
|
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||||
|
use App\Models\SofaScoreDay;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use UnitEnum;
|
||||||
|
|
||||||
|
class SofaScoreDayResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = SofaScoreDay::class;
|
||||||
|
|
||||||
|
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'Days';
|
||||||
|
|
||||||
|
protected static ?string $navigationLabel = 'Days';
|
||||||
|
|
||||||
|
protected static ?string $cluster = StaticDataCluster::class;
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return SofaScoreDayForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return SofaScoreDaysTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationBadge(): ?string
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListSofaScoreDays::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
|
use Filament\Tables\Columns\CheckboxColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Enums\FiltersLayout;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
class SofaScoreDaysTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->description('Sport checked is grapped, uncheck to grap data for specivic day again.')
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('day')->sortable(),
|
||||||
|
CheckboxColumn::make('football'),
|
||||||
|
CheckboxColumn::make('basketball'),
|
||||||
|
CheckboxColumn::make('ice-hockey'),
|
||||||
|
CheckboxColumn::make('tennis'),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Filter::make('day')
|
||||||
|
->columns(2)->columnSpan(2)
|
||||||
|
->schema([
|
||||||
|
DatePicker::make('from')->native(),
|
||||||
|
DatePicker::make('until')->native(),
|
||||||
|
])
|
||||||
|
->query(function (Builder $query, array $data): Builder {
|
||||||
|
return $query
|
||||||
|
->when(
|
||||||
|
$data['from'],
|
||||||
|
fn (Builder $query, $date): Builder => $query->whereDate('day', '>=', $date),
|
||||||
|
)
|
||||||
|
->when(
|
||||||
|
$data['until'],
|
||||||
|
fn (Builder $query, $date): Builder => $query->whereDate('day', '<=', $date),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
], layout: FiltersLayout::AboveContent)
|
||||||
|
->deferFilters(false)
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -40,7 +40,7 @@ class SofaScoreTournamentsTable
|
|||||||
TextColumn::make('sport.name'),
|
TextColumn::make('sport.name'),
|
||||||
TextColumn::make('sofascore_category.name')
|
TextColumn::make('sofascore_category.name')
|
||||||
->icon(fn ($record) => $record->sofascore_category->country->icon),
|
->icon(fn ($record) => $record->sofascore_category->country->icon),
|
||||||
TextColumn::make('name')->searchable(),
|
TextColumn::make('name')->searchable()->sortable(),
|
||||||
CheckboxColumn::make('grap'),
|
CheckboxColumn::make('grap'),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Schemas\TxoddsMarke
|
|||||||
use App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Tables\TxoddsMarketsTable;
|
use App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Tables\TxoddsMarketsTable;
|
||||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||||
use App\Models\TxoddsMarket;
|
use App\Models\TxoddsMarket;
|
||||||
use BackedEnum;
|
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
@@ -18,8 +17,6 @@ class TxoddsMarketResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $cluster = StaticDataCluster::class;
|
protected static ?string $cluster = StaticDataCluster::class;
|
||||||
|
|
||||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-tree-structure';
|
|
||||||
|
|
||||||
protected static ?int $navigationSort = 32;
|
protected static ?int $navigationSort = 32;
|
||||||
|
|
||||||
protected static string|\UnitEnum|null $navigationGroup = 'Markets';
|
protected static string|\UnitEnum|null $navigationGroup = 'Markets';
|
||||||
|
|||||||
+5
-1
@@ -127,6 +127,10 @@ return [
|
|||||||
'path' => storage_path('logs/laravel.log'),
|
'path' => storage_path('logs/laravel.log'),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'sofascore' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/sofascore.log'),
|
||||||
|
'level' => 'info',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
Reference in new issue
Block a user