reorder the cluser
This commit is contained in:
1 parent
7ad439258c
commit
79839c04a4
53 files changed
+755
-705
No files matched your search
@@ -21,7 +21,11 @@ class BettypeResource extends Resource
|
||||
|
||||
protected static ?string $navigationLabel = 'NuhOdds Markets';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
|
||||
protected static ?string $modelLabel = 'NuhOdds Markets';
|
||||
|
||||
protected static ?int $navigationSort = 31;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Markets';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitionGroups;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitionGroups\Pages\ListCompetitionGroups;
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitionGroups\Schemas\CompetitionGroupForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitionGroups\Tables\CompetitionGroupsTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\CompetitionGroup;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class CompetitionGroupResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CompetitionGroup::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-folder';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'TxOdds';
|
||||
|
||||
protected static ?string $modelLabel = 'Groups';
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
|
||||
protected static ?string $navigationLabel = 'Groups';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return CompetitionGroupForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return CompetitionGroupsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListCompetitionGroups::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'warning';
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitionGroups\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitionGroups\CompetitionGroupResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCompetitionGroup extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CompetitionGroupResource::class;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitionGroups\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitionGroups\CompetitionGroupResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCompetitionGroup extends EditRecord
|
||||
{
|
||||
protected static string $resource = CompetitionGroupResource::class;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitionGroups\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitionGroups\CompetitionGroupResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCompetitionGroups extends ListRecords
|
||||
{
|
||||
protected static string $resource = CompetitionGroupResource::class;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitionGroups\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class CompetitionGroupForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitionGroups\Tables;
|
||||
|
||||
use App\Filament\Exports\CompetitionGroupExporter;
|
||||
use App\Models\CompetitionGroupProvider;
|
||||
use App\Models\Country;
|
||||
use App\Models\ElementGroup;
|
||||
use App\Models\Event;
|
||||
use App\Models\Group;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ExportAction;
|
||||
use Filament\Actions\Exports\Enums\ExportFormat;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CompetitionGroupsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->grow(false)
|
||||
->color('primary')
|
||||
->width(30)
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
TextColumn::make('country.name')
|
||||
->wrap()
|
||||
->color('gray')
|
||||
->label('Country')
|
||||
->icon(fn ($record) => $record->country->icon),
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
SelectColumn::make('level')
|
||||
->width(30)
|
||||
->options([
|
||||
'TOP' => 'TOP',
|
||||
'MEDIUM' => 'MEDIUM',
|
||||
'LOW' => 'LOW',
|
||||
]),
|
||||
])->filters([
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->default(1)
|
||||
->selectablePlaceholder(false)
|
||||
->options(fn () => Sport::where('is_active', 1)->pluck('name', 'id')->toArray()),
|
||||
SelectFilter::make('country_id')
|
||||
->searchable()
|
||||
->label('Countries')
|
||||
->options(fn () => Country::orderBy('name')->pluck('name', 'id')->toArray()),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
ActionGroup::make([
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->tooltip('All elements connected to this group, including active events, will be deleted')
|
||||
->before(function ($record) {
|
||||
Group::where('competition_group_id', $record->id)->delete();
|
||||
Event::where('competition_group_id', $record->id)->delete();
|
||||
ElementGroup::where('competition_group_id', $record->id)->delete();
|
||||
CompetitionGroupProvider::where('competition_group_id', $record->id)->delete();
|
||||
})
|
||||
->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Group deleted')
|
||||
->body('The group and all relations has been deleted successfully.'),
|
||||
),
|
||||
])->iconButton()
|
||||
->icon('phosphor-dots-three-vertical'),
|
||||
])
|
||||
->headerActions([
|
||||
ExportAction::make()
|
||||
->modalHeading('Download Tournaments')
|
||||
->color('warning')
|
||||
->label('Export')
|
||||
->icon('phosphor-download')
|
||||
->modalDescription('This will download the TxOdds tournaments with "sport_id" and "country_id" for the sport selected.')
|
||||
->modalIcon('phosphor-microsoft-excel-logo')
|
||||
->exporter(CompetitionGroupExporter::class)
|
||||
->columnMapping(false)
|
||||
->formats([
|
||||
ExportFormat::Xlsx,
|
||||
ExportFormat::Csv,
|
||||
]),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\Pages\ListCompetitonGroupProviders;
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\Schemas\CompetitonGroupProviderForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\Tables\CompetitonGroupProvidersTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\CompetitionGroupProvider;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class CompetitonGroupProviderResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CompetitionGroupProvider::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-folder';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $modelLabel = 'Provider Groups';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 22;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Provider Relations';
|
||||
|
||||
protected static ?string $navigationLabel = 'Provider Groups';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return CompetitonGroupProviderForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return CompetitonGroupProvidersTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListCompetitonGroupProviders::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\CompetitonGroupProviderResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCompetitonGroupProvider extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CompetitonGroupProviderResource::class;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\CompetitonGroupProviderResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCompetitonGroupProvider extends EditRecord
|
||||
{
|
||||
protected static string $resource = CompetitonGroupProviderResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\CompetitonGroupProviderResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCompetitonGroupProviders extends ListRecords
|
||||
{
|
||||
protected static string $resource = CompetitonGroupProviderResource::class;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class CompetitonGroupProviderForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\Tables;
|
||||
|
||||
use App\Models\AddByMethod;
|
||||
use App\Models\Country;
|
||||
use App\Models\Provider;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CompetitonGroupProvidersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->grow(false)
|
||||
->color('primary')
|
||||
->width(30)
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
TextColumn::make('provider.name')->color(fn ($record) => $record->provider->color),
|
||||
TextColumn::make('competition_group.country.name')
|
||||
->wrap()
|
||||
->color('gray')
|
||||
->label('Country')
|
||||
->icon(fn ($record) => $record->competition_group->country->icon),
|
||||
TextColumn::make('competition_group.name')
|
||||
->label('Provider')
|
||||
->searchable(),
|
||||
TextColumn::make('provider_group_id')->label('PrId')->alignCenter(),
|
||||
TextColumn::make('id')->label('TxId')->alignCenter(),
|
||||
TextColumn::make('name')
|
||||
->label('TxOdds')
|
||||
->searchable(),
|
||||
TextColumn::make('add_by_method.name')
|
||||
->color(fn ($record) => $record->add_by_method->color)
|
||||
->label('Add By'),
|
||||
])->filters([
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->options(Sport::where('is_active', 1)->pluck('name', 'id')),
|
||||
SelectFilter::make('country_id')
|
||||
->searchable()
|
||||
->label('Country')
|
||||
->options(Country::orderBy('name')->pluck('name', 'id'))
|
||||
->query(function (Builder $query, array $data) {
|
||||
if (blank($data['value'])) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
return $query->whereHas('competition_group', function (Builder $query) use ($data) {
|
||||
return $query->where('country_id', $data['value']);
|
||||
});
|
||||
}),
|
||||
SelectFilter::make('provider_id')
|
||||
->label('Provider')
|
||||
->options(Provider::where('color', '!=', null)->pluck('name', 'id')),
|
||||
SelectFilter::make('add_by_method_id')
|
||||
->label('Provider')
|
||||
->options(AddByMethod::pluck('name', 'id')),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
ActionGroup::make([
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Group deleted')
|
||||
->body('The provider group has been deleted successfully.'),
|
||||
),
|
||||
])->iconButton()
|
||||
->icon('phosphor-dots-three-vertical'),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -26,13 +26,13 @@ class CountryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Country::class;
|
||||
|
||||
protected static ?int $navigationSort = 22;
|
||||
protected static ?int $navigationSort = 13;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-flag';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-folder';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'TxOdds';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -87,6 +87,7 @@ class CountryResource extends Resource
|
||||
ExportAction::make()
|
||||
->modalHeading('Download Countries')
|
||||
->label('Export')
|
||||
->color('warning')
|
||||
->icon('phosphor-download')
|
||||
->modalDescription('This will download the Countries (id, name) from TxOdds.')
|
||||
->modalIcon('phosphor-microsoft-excel-logo')
|
||||
@@ -108,6 +109,11 @@ class CountryResource extends Resource
|
||||
return parent::getEloquentQuery()->where('disabled', false)->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('disabled', false);
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\ElementProviders;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\ElementProviders\Pages\ListElementProviders;
|
||||
use App\Filament\Clusters\StaticData\Resources\ElementProviders\Schemas\ElementProviderForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\ElementProviders\Tables\ElementProvidersTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\ElementProvider;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class ElementProviderResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ElementProvider::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-folder';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 21;
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Provider Relations';
|
||||
|
||||
protected static ?string $navigationLabel = 'Provider Elements';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ElementProviderForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ElementProvidersTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListElementProviders::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\ElementProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\ElementProviders\ElementProviderResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateElementProvider extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ElementProviderResource::class;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\ElementProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\ElementProviders\ElementProviderResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditElementProvider extends EditRecord
|
||||
{
|
||||
protected static string $resource = ElementProviderResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\ElementProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\ElementProviders\ElementProviderResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListElementProviders extends ListRecords
|
||||
{
|
||||
protected static string $resource = ElementProviderResource::class;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\ElementProviders\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ElementProviderForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label('Client Name')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\ElementProviders\Tables;
|
||||
|
||||
use App\Models\AddByMethod;
|
||||
use App\Models\Country;
|
||||
use App\Models\Provider;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
|
||||
class ElementProvidersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->grow(false)
|
||||
->color('primary')
|
||||
->width(30)
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
TextColumn::make('provider.name')->color(fn ($record) => $record->provider->color),
|
||||
TextColumn::make('element.country.name')
|
||||
->wrap()
|
||||
->color('gray')
|
||||
->icon(fn ($record) => $record->element->country->icon),
|
||||
TextColumn::make('id')->label('TxId')->alignCenter(),
|
||||
TextColumn::make('provider_element_id')->label('PrId')->alignCenter(),
|
||||
TextColumn::make('element_group.competition_group.name')->label('Group'),
|
||||
TextColumn::make('element.name')->label('TxOdds'),
|
||||
TextColumn::make('name')->label('Client')->searchable(),
|
||||
TextColumn::make('add_by_method.name')
|
||||
->color(fn ($record) => $record->add_by_method->color)
|
||||
->label('Add By'),
|
||||
])->filters([
|
||||
SelectFilter::make('provider_id')
|
||||
->label('Provider')
|
||||
->options(Provider::where('bookmaker_id', '>', 0)->pluck('name', 'id')),
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->options(Sport::where('is_active', 1)->pluck('name', 'id')),
|
||||
SelectFilter::make('country_id')
|
||||
->searchable()
|
||||
->label('Country')
|
||||
->options(Country::orderBy('name')->pluck('name', 'id'))
|
||||
->query(function (Builder $query, array $data) {
|
||||
if (blank($data['value'])) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
return $query->whereHas('element', function (Builder $query) use ($data) {
|
||||
return $query->where('country_id', $data['value']);
|
||||
});
|
||||
}),
|
||||
SelectFilter::make('add_by_method_id')
|
||||
->label('Add By')
|
||||
->options(AddByMethod::pluck('name', 'id')),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
ActionGroup::make([
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Element deleted')
|
||||
->body('The provider element has been deleted successfully.'),
|
||||
),
|
||||
])->iconButton()
|
||||
->icon('phosphor-dots-three-vertical'),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Elements;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Elements\Pages\ListElements;
|
||||
use App\Filament\Clusters\StaticData\Resources\Elements\Schemas\ElementForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\Elements\Tables\ElementsTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\Element;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class ElementResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Element::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-folder';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'TxOdds';
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ElementForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ElementsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListElements::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'warning';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Elements\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Elements\ElementResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateElement extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ElementResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Elements\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Elements\ElementResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditElement extends EditRecord
|
||||
{
|
||||
protected static string $resource = ElementResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Elements\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Elements\ElementResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListElements extends ListRecords
|
||||
{
|
||||
protected static string $resource = ElementResource::class;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Elements\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ElementForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Elements\Tables;
|
||||
|
||||
use App\Filament\Exports\ElementExporter;
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Country;
|
||||
use App\Models\ElementGroup;
|
||||
use App\Models\ElementProvider;
|
||||
use App\Models\Event;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ExportAction;
|
||||
use Filament\Actions\Exports\Enums\ExportFormat;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ElementsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->grow(false)
|
||||
->color('primary')
|
||||
->width(30)
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
TextColumn::make('id')
|
||||
->tooltip('click to copy')
|
||||
->alignCenter()
|
||||
->copyable(),
|
||||
TextColumn::make('country.name')
|
||||
->wrap()
|
||||
->color('gray')
|
||||
->icon(fn ($record) => $record->country->icon),
|
||||
TextColumn::make('element_group.competition_group_id')->label('Group Id')
|
||||
->alignCenter()
|
||||
->tooltip('click to copy')
|
||||
->copyable(),
|
||||
TextColumn::make('element_group.competition_group.name')->label('Group'),
|
||||
// TextColumn::make('element_group.group.name')->label('Group'),
|
||||
ImageColumn::make('betsapi_image_id')
|
||||
->label('Logo')
|
||||
->defaultImageUrl(fn ($state) => url('https://assets.b365api.com/images/team/m/'.$state.'.png')),
|
||||
TextColumn::make('name')->searchable(),
|
||||
])->filters([
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->options(Sport::where('is_active', 1)->pluck('name', 'id')),
|
||||
Filter::make('competition_group')
|
||||
->columns(3)->columnSpan(3)
|
||||
->schema([
|
||||
Select::make('country_id')
|
||||
->searchable()
|
||||
->label('Country')
|
||||
->options(Country::orderBy('name')->pluck('name', 'id'))
|
||||
->live(),
|
||||
Select::make('competition_group_id')
|
||||
->searchable()
|
||||
->label('Competition Group')
|
||||
->options(function (Get $get) {
|
||||
if ($get('country_id')) {
|
||||
return CompetitionGroup::where('country_id', $get('country_id'))->orderBy('name')->pluck('name', 'id');
|
||||
} else {
|
||||
return CompetitionGroup::orderBy('name')->pluck('name', 'id');
|
||||
}
|
||||
}),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['country_id'],
|
||||
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
|
||||
)->when(
|
||||
$data['competition_group_id'],
|
||||
function (Builder $query, $competition_group_id) {
|
||||
return $query->whereHas('element_group', function (Builder $query) use ($competition_group_id) {
|
||||
return $query->where('competition_group_id', $competition_group_id);
|
||||
});
|
||||
}
|
||||
);
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
ActionGroup::make([
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->tooltip('All elements connected to this group, including active events, will be deleted')
|
||||
->before(function ($record) {
|
||||
Event::where('home_id', $record->id)->delete();
|
||||
Event::where('away_id', $record->id)->delete();
|
||||
ElementProvider::where('element_id', $record->id)->delete();
|
||||
ElementGroup::where('element_id', $record->id)->delete();
|
||||
})
|
||||
->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Element deleted')
|
||||
->body('The element with all relations in other tables has been deleted successfully.'),
|
||||
),
|
||||
])->iconButton()
|
||||
->icon('phosphor-dots-three-vertical'),
|
||||
])
|
||||
->headerActions([
|
||||
ExportAction::make()
|
||||
->modalHeading('Download Teams/Player')
|
||||
->color('warning')
|
||||
->label('Export')
|
||||
->icon('phosphor-download')
|
||||
->modalDescription('This will download the TxOdds Teams/Player with "sport_id" and "country_id" for the sport selected.')
|
||||
->modalIcon('phosphor-microsoft-excel-logo')
|
||||
->exporter(ElementExporter::class)
|
||||
->columnMapping(false)
|
||||
->formats([
|
||||
ExportFormat::Xlsx,
|
||||
ExportFormat::Csv,
|
||||
]),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class PlayersTable
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
Stack::make([
|
||||
TextColumn::make('name')
|
||||
|
||||
@@ -17,15 +17,15 @@ class SportResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Sport::class;
|
||||
|
||||
protected static ?int $navigationSort = 24;
|
||||
protected static ?int $navigationSort = 13;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-volleyball';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-folder';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'TxOdds';
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ class TxoddsMarketsTable
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
TextColumn::make('market_id')->badge()->searchable(),
|
||||
TextColumn::make('name')->searchable(),
|
||||
|
||||
@@ -19,9 +19,11 @@ class TxoddsMarketResource extends Resource
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?int $navigationSort = 32;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Markets';
|
||||
|
||||
protected static ?string $modelLabel = 'TxOdds Markets';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ class ListUbEvents extends ListRecords
|
||||
return [
|
||||
ImportAction::make('importPlayer')
|
||||
->icon('phosphor-upload')
|
||||
->color('success')
|
||||
->label('Import')
|
||||
->modalIcon('phosphor-file-csv')
|
||||
->modalDescription('Separator ";"')
|
||||
|
||||
@@ -21,6 +21,7 @@ class UbEventsTable
|
||||
{
|
||||
return $table
|
||||
->poll('10sec')
|
||||
->striped()
|
||||
->columns([
|
||||
TextColumn::make('starttime')->dateTime('d. M. Y')->label('Date'),
|
||||
TextColumn::make('league.name')->searchable(),
|
||||
|
||||
@@ -12,6 +12,7 @@ use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use UnitEnum;
|
||||
|
||||
class UbEventResource extends Resource
|
||||
{
|
||||
@@ -21,8 +22,14 @@ class UbEventResource extends Resource
|
||||
|
||||
protected static ?string $navigationLabel = 'Event & Player';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $modelLabel = 'Events & Players';
|
||||
|
||||
// protected static ?string $recordTitleAttribute = 'league_id';
|
||||
|
||||
public static function getRecordTitle($record): string|null|Htmlable
|
||||
@@ -51,4 +58,9 @@ class UbEventResource extends Resource
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ class ListUbPlayers extends ListRecords
|
||||
->icon('phosphor-plus'),
|
||||
ImportAction::make('importPlayer')
|
||||
->maxRows(200000)
|
||||
->color('success')
|
||||
->chunkSize(250)
|
||||
->icon('phosphor-upload')
|
||||
->label('Import')
|
||||
|
||||
@@ -14,6 +14,7 @@ class UbPlayersTable
|
||||
{
|
||||
return $table
|
||||
->poll('10sec')
|
||||
->striped()
|
||||
->defaultPaginationPageOption(8)
|
||||
->paginationPageOptions([8, 16, 24, 36])
|
||||
->columns([
|
||||
|
||||
@@ -11,6 +11,7 @@ use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class UbPlayerResource extends Resource
|
||||
{
|
||||
@@ -20,8 +21,14 @@ class UbPlayerResource extends Resource
|
||||
|
||||
protected static ?string $navigationLabel = 'Player';
|
||||
|
||||
protected static ?string $modelLabel = 'Players';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'giocatore';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
@@ -45,4 +52,9 @@ class UbPlayerResource extends Resource
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user