add txodds markets as a resource
This commit is contained in:
1 parent
e14404ec8b
commit
5fa1d02dbd
26 files changed
+921
-55
No files matched your search
@@ -21,13 +21,13 @@ class SupervisorForm
|
||||
->relationship('sport', 'name')
|
||||
->nullable(),
|
||||
|
||||
TextInput::make('sleep')->default(15),
|
||||
TextInput::make('sleep')->default(30),
|
||||
TextInput::make('maxsconds')->label('Seconds till throwing an error')->default(1800),
|
||||
Section::make('Run processes paralell for speed')
|
||||
->description('Set start and end days if more processes grap the same data')
|
||||
->schema([
|
||||
TextInput::make('days_from')->columns(1),
|
||||
TextInput::make('days_to')->columns(1),
|
||||
TextInput::make('days_from')->columns(1)->default(0),
|
||||
TextInput::make('days_to')->columns(1)->default(1),
|
||||
])->columns(2)->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -33,13 +33,6 @@ class SupervisorResource extends Resource
|
||||
return SupervisorsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -34,14 +34,35 @@ class SupervisorsTable
|
||||
default => 'warning',
|
||||
}),
|
||||
SelectColumn::make('name')
|
||||
->options([
|
||||
'Fixtures' => 'Fixtures',
|
||||
'Odds' => 'Odds',
|
||||
'Willhill' => 'Willhill',
|
||||
'Bwin' => 'Bwin',
|
||||
'Bet365' => 'Bet365',
|
||||
'Betfair' => 'Betfair',
|
||||
]),
|
||||
->options(function ($record) {
|
||||
switch ($record->provider_id) {
|
||||
case 1:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
return [
|
||||
'Fixtures' => 'Fixtures',
|
||||
'Odds' => 'Odds',
|
||||
];
|
||||
case 2:
|
||||
return [
|
||||
'Fixtures' => 'Fixtures',
|
||||
'Odds' => 'Odds',
|
||||
'Willhill' => 'Willhill',
|
||||
'Bwin' => 'Bwin',
|
||||
'Bet365' => 'Bet365',
|
||||
'Betfair' => 'Betfair',
|
||||
];
|
||||
case 7:
|
||||
return [
|
||||
'Txodds Markets' => 'Txodds Markets',
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
||||
}),
|
||||
TextColumn::make('sport.name')->label('Sport'),
|
||||
TextColumn::make('days_from')->label('From'),
|
||||
TextColumn::make('days_to')->label('To'),
|
||||
@@ -50,9 +71,9 @@ class SupervisorsTable
|
||||
TextInputColumn::make('commandline_options')->width('2rem'),
|
||||
|
||||
// TextColumn::make('maxsconds')->label('Max Time'),
|
||||
// IconColumn::make('is_cron')->boolean()->label('Cron')->falseColor('gray'),
|
||||
// IconColumn::make('is_supervisor')->boolean()->label('Cron')->falseColor('gray'),
|
||||
ToggleColumn::make('use_lastcall')->label('Lastcall'),
|
||||
ToggleColumn::make('is_cron')->label('Cron'),
|
||||
ToggleColumn::make('is_supervisor')->label('Super')->tooltip('Create a supervisor process'),
|
||||
ToggleColumn::make('is_active')->label('Active'),
|
||||
])
|
||||
->filters([
|
||||
@@ -60,7 +81,7 @@ class SupervisorsTable
|
||||
->default(1)
|
||||
->relationship('provider', 'name')
|
||||
->label('Provider'),
|
||||
TernaryFilter::make('is_cron'),
|
||||
TernaryFilter::make('is_supervisor'),
|
||||
TernaryFilter::make('is_active'),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Pages;
|
||||
|
||||
use App\Filament\Resources\TxoddsMarkets\TxoddsMarketResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTxoddsMarket extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TxoddsMarketResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Pages;
|
||||
|
||||
use App\Filament\Resources\TxoddsMarkets\TxoddsMarketResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTxoddsMarket extends EditRecord
|
||||
{
|
||||
protected static string $resource = TxoddsMarketResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Pages;
|
||||
|
||||
use App\Filament\Resources\TxoddsMarkets\TxoddsMarketResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTxoddsMarkets extends ListRecords
|
||||
{
|
||||
protected static string $resource = TxoddsMarketResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TxoddsMarketForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Tables;
|
||||
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TxoddsMarketsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('market_id')->badge()->searchable(),
|
||||
TextColumn::make('name')->searchable(),
|
||||
ToggleColumn::make('soccer')->toggleable(true),
|
||||
ToggleColumn::make('ice_hockey')->toggleable(true),
|
||||
ToggleColumn::make('basketball')->toggleable(true),
|
||||
ToggleColumn::make('tennis')->toggleable(true),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('sport_market')
|
||||
->schema([
|
||||
Select::make(name: 'sport_market')
|
||||
->placeholder('Filter Sport')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->preload()
|
||||
->options(function () {
|
||||
return [
|
||||
'soccer' => 'Soccer',
|
||||
'ice_hockey' => 'Ice Hockey',
|
||||
'basketball' => 'Basketball',
|
||||
'tennis' => 'Tennis',
|
||||
];
|
||||
})
|
||||
->live(),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['sport_market'],
|
||||
fn (Builder $query, $sport_market) => $query->where($sport_market, 1)
|
||||
);
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferColumnManager(false)
|
||||
->deferFilters(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets;
|
||||
|
||||
use App\Filament\Clusters\Administrator\AdministratorCluster;
|
||||
use App\Filament\Resources\TxoddsMarkets\Pages\ListTxoddsMarkets;
|
||||
use App\Filament\Resources\TxoddsMarkets\Schemas\TxoddsMarketForm;
|
||||
use App\Filament\Resources\TxoddsMarkets\Tables\TxoddsMarketsTable;
|
||||
use App\Models\TxoddsMarket;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class TxoddsMarketResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TxoddsMarket::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-storefront';
|
||||
|
||||
protected static ?string $cluster = AdministratorCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 24;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Grapper';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TxoddsMarketForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TxoddsMarketsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTxoddsMarkets::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user