wip del err
This commit is contained in:
1 parent
812736ca9a
commit
9bcd4432c6
1210 files changed
-220941
No files matched your search
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
|
||||
class GrapperCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-rss';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Bookmakers;
|
||||
|
||||
use App\Filament\Clusters\Grapper\GrapperCluster;
|
||||
use App\Filament\Clusters\Grapper\Resources\Bookmakers\Pages\ListBookmakers;
|
||||
use App\Filament\Clusters\Grapper\Resources\Bookmakers\Schemas\BookmakerForm;
|
||||
use App\Filament\Clusters\Grapper\Resources\Bookmakers\Tables\BookmakersTable;
|
||||
use App\Models\Bookmaker;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class BookmakerResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Bookmaker::class;
|
||||
|
||||
protected static ?int $navigationSort = 21;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-bookmarks-simple';
|
||||
|
||||
protected static ?string $cluster = GrapperCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Grapper';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return BookmakerForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return BookmakersTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBookmakers::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('deleted', false);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Bookmakers\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\Bookmakers\BookmakerResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBookmaker extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BookmakerResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Bookmakers\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\Bookmakers\BookmakerResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditBookmaker extends EditRecord
|
||||
{
|
||||
protected static string $resource = BookmakerResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Bookmakers\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\Bookmakers\BookmakerResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBookmakers extends ListRecords
|
||||
{
|
||||
protected static string $resource = BookmakerResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Bookmakers\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BookmakerForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('icon')
|
||||
->required(),
|
||||
TextInput::make('baid')
|
||||
->numeric()
|
||||
->default(0),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Bookmakers\Tables;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BookmakersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->defaultPaginationPageOption(5)
|
||||
->columns([
|
||||
TextColumn::make('id')->searchable(),
|
||||
TextColumn::make('name')->searchable(),
|
||||
BookmakerIcon::make('icon')->label('Icon')->size('lg'),
|
||||
ToggleColumn::make('in_soccer')->onColor('success'),
|
||||
ToggleColumn::make('in_other')->onColor('success'),
|
||||
ToggleColumn::make('txso'),
|
||||
ToggleColumn::make('txot'),
|
||||
ToggleColumn::make('betsapi'),
|
||||
ToggleColumn::make('direct'),
|
||||
ToggleColumn::make('is_active')->onColor('success'),
|
||||
ToggleColumn::make('need_check')->onColor('danger'),
|
||||
])
|
||||
->defaultSort('id')
|
||||
->filters([
|
||||
TernaryFilter::make('in_soccer'),
|
||||
TernaryFilter::make('in_other'),
|
||||
TernaryFilter::make('txso'),
|
||||
TernaryFilter::make('txot'),
|
||||
TernaryFilter::make('betsapi'),
|
||||
TernaryFilter::make('direct'),
|
||||
TernaryFilter::make('is_active')->default(true),
|
||||
TernaryFilter::make('need_check'),
|
||||
], FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make()->hiddenLabel(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Providers\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\Providers\ProviderResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProvider extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProviderResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Providers\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\Providers\ProviderResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProvider extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProviderResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Providers\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\Providers\ProviderResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListProviders extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProviderResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Providers;
|
||||
|
||||
use App\Filament\Clusters\Grapper\GrapperCluster;
|
||||
use App\Filament\Clusters\Grapper\Resources\Providers\Pages\ListProviders;
|
||||
use App\Filament\Clusters\Grapper\Resources\Providers\Schemas\ProviderForm;
|
||||
use App\Filament\Clusters\Grapper\Resources\Providers\Tables\ProvidersTable;
|
||||
use App\Models\Provider;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProviderResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Provider::class;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-books';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = GrapperCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Grapper';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ProviderForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ProvidersTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListProviders::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Providers\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ProviderForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Providers\Tables;
|
||||
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProvidersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->recordAction(null)
|
||||
->columns([
|
||||
TextColumn::make('id')->alignCenter()->badge(),
|
||||
TextColumn::make('name'),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->hiddenLabel(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Supervisors\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\Supervisors\SupervisorResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSupervisor extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SupervisorResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Supervisors\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\Supervisors\SupervisorResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSupervisor extends EditRecord
|
||||
{
|
||||
protected static string $resource = SupervisorResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Supervisors\Pages;
|
||||
|
||||
use App\Actions\SupervisorStatus;
|
||||
use App\Filament\Clusters\Grapper\Resources\Supervisors\SupervisorResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSupervisors extends ListRecords
|
||||
{
|
||||
protected static string $resource = SupervisorResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make()->label('New')->icon('phosphor-plus'),
|
||||
Action::make('stop_all')->icon('phosphor-prohibit')->action(function (): void {
|
||||
SupervisorStatus::set(0);
|
||||
}),
|
||||
Action::make('start_all')->icon('phosphor-play')->action(function (): void {
|
||||
SupervisorStatus::set(1);
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Supervisors\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SupervisorForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('provider_id')
|
||||
->relationship('provider', 'name')
|
||||
->required()
|
||||
->preload(),
|
||||
Select::make('sport_id')
|
||||
->relationship('sport', 'name')
|
||||
->nullable(),
|
||||
|
||||
// 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)->default(0),
|
||||
// TextInput::make('days_to')->columns(1)->default(1),
|
||||
// ])->columns(2)->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Supervisors;
|
||||
|
||||
use App\Filament\Clusters\Grapper\GrapperCluster;
|
||||
use App\Filament\Clusters\Grapper\Resources\Supervisors\Pages\ListSupervisors;
|
||||
use App\Filament\Clusters\Grapper\Resources\Supervisors\Schemas\SupervisorForm;
|
||||
use App\Filament\Clusters\Grapper\Resources\Supervisors\Tables\SupervisorsTable;
|
||||
use App\Models\Supervisor;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class SupervisorResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Supervisor::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-network';
|
||||
|
||||
protected static ?string $cluster = GrapperCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Grapper';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SupervisorForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return SupervisorsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListSupervisors::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -1,261 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\Supervisors\Tables;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\Supervisors\Pages\ListSupervisors;
|
||||
use App\Models\Sport;
|
||||
use App\Models\Supervisor;
|
||||
use App\Models\TxoddsMarket;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\TextSize;
|
||||
use Filament\Tables\Columns\Layout\Split;
|
||||
use Filament\Tables\Columns\Layout\Stack;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class SupervisorsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->recordAction(null)
|
||||
->poll('15s')
|
||||
->columns([
|
||||
Split::make([
|
||||
TextColumn::make('id')->badge()->alignCenter()
|
||||
->color('black ')
|
||||
->weight(FontWeight::Black)
|
||||
->size(TextSize::Large),
|
||||
TextColumn::make('provider.name')
|
||||
->color(fn ($record): string => match ($record->provider_id) {
|
||||
1 => 'danger',
|
||||
8 => 'danger',
|
||||
2 => 'success',
|
||||
11 => 'info',
|
||||
default => 'warning',
|
||||
}),
|
||||
Stack::make([
|
||||
SelectColumn::make('name')
|
||||
->selectablePlaceholder(true)
|
||||
->hidden(function (ListSupervisors $livewire) {
|
||||
return (bool) in_array($livewire->tableFilters['provider_id']['value'], [8,12]);
|
||||
})
|
||||
->options(function ($record) {
|
||||
switch ($record->provider_id) {
|
||||
case 1:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
return [
|
||||
'Fixtures' => 'Fixtures',
|
||||
'Odds' => 'Odds',
|
||||
'Countries' => 'Countries',
|
||||
'Groups' => 'Groups',
|
||||
'Major Groups' => 'Major Groups',
|
||||
];
|
||||
case 2:
|
||||
return [
|
||||
'Fixtures' => 'Fixtures',
|
||||
'Odds' => 'Odds',
|
||||
'Willhill' => 'Willhill',
|
||||
'Bwin' => 'Bwin',
|
||||
'Bet365' => 'Bet365',
|
||||
'Betfair' => 'Betfair',
|
||||
'Element Icons' => 'Element Icons',
|
||||
];
|
||||
case 7:
|
||||
/**
|
||||
* functions for services
|
||||
*/
|
||||
return [
|
||||
'Txodds Markets' => 'Txodds Markets',
|
||||
'Txodds Flags' => 'Txodds Flags',
|
||||
'DB Mapper' => 'DB Mapper',
|
||||
'Generate Setting' => 'Generate Setting',
|
||||
'Generate Alarms' => 'Generate Alarms',
|
||||
'Notify Alarms' => 'Notify Alarms',
|
||||
];
|
||||
case 9:
|
||||
case 10:
|
||||
return [
|
||||
'GRAPPER DIRCET' => 'GRAPPER DIRCET',
|
||||
];
|
||||
case 11:
|
||||
return [
|
||||
'Bet365' => 'Bet365',
|
||||
'MAGLOO KENIA' => 'MAGLOO KENIA',
|
||||
'MAGLOO NIGERIA' => 'MAGLOO NIGERIA',
|
||||
'LOGIFUTURE NIGERA' => 'LOGIFUTURE NIGERA',
|
||||
'LOGIFUTURE COLOMBIA' => 'LOGIFUTURE COLOMBIA',
|
||||
];
|
||||
case 12:
|
||||
return [
|
||||
'TOURNAMENTS' => 'TOURNAMENTS',
|
||||
'EVENTS' => 'EVENTS Comandline',
|
||||
'EVENTSDB' => 'EVENTS Database',
|
||||
'SPECIAL' => 'SPECIAL',
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}),
|
||||
SelectColumn::make('sport_id')
|
||||
->hidden(function (ListSupervisors $livewire) {
|
||||
return in_array($livewire->tableFilters['provider_id']['value'], [11, 12]);
|
||||
})
|
||||
->options(fn () => Sport::where('is_active', 1)->pluck('name', 'id'))
|
||||
->placeholder('All'),
|
||||
SelectColumn::make('txodds_market_id')
|
||||
->visible(function (ListSupervisors $livewire) {
|
||||
return $livewire->tableFilters['provider_id']['value'] == 8;
|
||||
})
|
||||
->options(function ($record) {
|
||||
switch ($record->sport_id) {
|
||||
case 1:
|
||||
return TxoddsMarket::where('soccer', 1)->pluck('name', 'market_id');
|
||||
case 2:
|
||||
return TxoddsMarket::where('ice_hockey', 1)->pluck('name', 'market_id');
|
||||
case 3:
|
||||
return TxoddsMarket::where('basketball', 1)->pluck('name', 'market_id');
|
||||
case 5:
|
||||
return TxoddsMarket::where('tennis', 1)->pluck('name', 'market_id');
|
||||
}
|
||||
})
|
||||
->placeholder('All Markets'),
|
||||
])->space(3),
|
||||
|
||||
Stack::make([
|
||||
TextInputColumn::make('days_from')->prefix('Days Fr')
|
||||
->hidden(function (ListSupervisors $livewire) {
|
||||
return in_array($livewire->tableFilters['provider_id']['value'], [7, 8, 11, 12]);
|
||||
}),
|
||||
TextInputColumn::make('days_to')->prefix('Days To')
|
||||
->hidden(function (ListSupervisors $livewire) {
|
||||
return in_array($livewire->tableFilters['provider_id']['value'], [7, 8, 11, 12]);
|
||||
}),
|
||||
])->space(3),
|
||||
Stack::make([
|
||||
TextColumn::make('lastcall')
|
||||
->prefix('Lastcall: ')
|
||||
->badge()
|
||||
->color(fn ($state): string => ($state > 0 && $state > time() - 300) ? 'success' : 'danger')
|
||||
->dateTime()
|
||||
->visible(function (ListSupervisors $livewire) {
|
||||
return $livewire->tableFilters['provider_id']['value'] == 8;
|
||||
}),
|
||||
TextInputColumn::make('sleep')->prefix('Seep')
|
||||
->hidden(function (ListSupervisors $livewire) {
|
||||
return in_array($livewire->tableFilters['provider_id']['value'], [8, 12]);
|
||||
}),
|
||||
TextInputColumn::make('commandline_options')->prefix('Bash')
|
||||
->tooltip('command used in supervisor script')
|
||||
->hidden(function (ListSupervisors $livewire) {
|
||||
return in_array($livewire->tableFilters['provider_id']['value'], [8, 12]);
|
||||
}),
|
||||
])->space(3),
|
||||
SelectColumn::make('is_supervisor')
|
||||
->allowOptionsHtml()
|
||||
->native(false)
|
||||
->options([
|
||||
'0' => '<span class="text-amber-600">Cronjob</span>',
|
||||
'1' => '<span class="text-blue-600">Supervisor</span>',
|
||||
'2' => '<span class="text-green-600">LaunchAgents</span>',
|
||||
]),
|
||||
ToggleColumn::make('is_active')->label('Active')->tooltip(('On/Off'))->onColor('success')->offColor('danger'),
|
||||
TextColumn::make('runtime')->badge()->prefix('Runtime: '),
|
||||
]),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('provider_id')
|
||||
->selectablePlaceholder(false)
|
||||
->relationship('provider', 'name')
|
||||
->label('Provider'),
|
||||
SelectFilter::make('sport_id')
|
||||
->relationship('sport', 'name')
|
||||
->label('Sport'),
|
||||
TernaryFilter::make('is_supervisor')->label('Run by supervisor'),
|
||||
TernaryFilter::make('is_active'),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->persistFiltersInSession()
|
||||
->recordActions([
|
||||
EditAction::make()->hiddenLabel(),
|
||||
DeleteAction::make()->hiddenLabel(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('sleep')
|
||||
->label('Sleep')
|
||||
->icon('phosphor-timer')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
Supervisor::where('id', '=', $record->id)
|
||||
->update(
|
||||
['sleep' => $data['sleep']]
|
||||
);
|
||||
}
|
||||
})
|
||||
->form([
|
||||
TextInput::make('sleep')->hiddenLabel()->prefix('Sleep'),
|
||||
]),
|
||||
BulkAction::make('Switch On')
|
||||
->icon('phosphor-play')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
Supervisor::where('id', '=', $record->id)
|
||||
->update(
|
||||
['is_active' => 1]
|
||||
);
|
||||
}
|
||||
}),
|
||||
BulkAction::make('Switch Off')
|
||||
->icon('phosphor-stop')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
Supervisor::where('id', '=', $record->id)
|
||||
->update(
|
||||
['is_active' => 0]
|
||||
);
|
||||
}
|
||||
}),
|
||||
BulkAction::make('As supervisor')
|
||||
->icon('phosphor-play')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
Supervisor::where('id', '=', $record->id)
|
||||
->update(
|
||||
['is_supervisor' => 1]
|
||||
);
|
||||
}
|
||||
}),
|
||||
BulkAction::make('Not as supervisor')
|
||||
->icon('phosphor-stop')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
Supervisor::where('id', '=', $record->id)
|
||||
->update(
|
||||
['is_supervisor' => 0]
|
||||
);
|
||||
}
|
||||
}),
|
||||
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user