dynamic elements and groups
This commit is contained in:
1 parent
80db5b6c6d
commit
0c3142f2fd
42 files changed
+798
-17
No files matched your search
@@ -12,6 +12,7 @@ class StoreElement
|
||||
$home['sport_id'] = $mapper['sport_id'];
|
||||
$home['element_id'] = $mapper['txodds_home_id'];
|
||||
$home['provider_id'] = $mapper['provider_id'];
|
||||
$home['add_by_method_id'] = 3;
|
||||
$home['name'] = $mapper['home'];
|
||||
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper['home_id']], $home);
|
||||
@@ -20,6 +21,7 @@ class StoreElement
|
||||
$away['sport_id'] = $mapper['sport_id'];
|
||||
$away['element_id'] = $mapper['txodds_away_id'];
|
||||
$away['provider_id'] = $mapper['provider_id'];
|
||||
$home['add_by_method_id'] = 3;
|
||||
$away['name'] = $mapper['away'];
|
||||
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper['away_id']], $away);
|
||||
|
||||
@@ -12,6 +12,7 @@ class StoreGroup
|
||||
$group['sport_id'] = $mapper['sport_id'];
|
||||
$group['competition_group_id'] = $mapper['txodds_group_id'];
|
||||
$group['provider_id'] = $mapper['provider_id'];
|
||||
$home['add_by_method_id'] = 3;
|
||||
$group['name'] = $mapper['group'];
|
||||
|
||||
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $mapper['group_id']], $group);
|
||||
|
||||
@@ -20,6 +20,7 @@ class StoreData
|
||||
$ele['sport_id'] = $event['sport_id'];
|
||||
$ele['provider_id'] = $event['provider_id'];
|
||||
$ele['element_id'] = $match->home_id ?? 0;
|
||||
$home['add_by_method_id'] = 1;
|
||||
$ele['name'] = $event['home'];
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['home_id']], $ele);
|
||||
}
|
||||
@@ -29,6 +30,7 @@ class StoreData
|
||||
$ele['sport_id'] = $event['sport_id'];
|
||||
$ele['provider_id'] = $event['provider_id'];
|
||||
$ele['element_id'] = $match->away_id ?? 0;
|
||||
$home['add_by_method_id'] = 1;
|
||||
$ele['name'] = $event['away'];
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['away_id']], $ele);
|
||||
}
|
||||
@@ -38,6 +40,7 @@ class StoreData
|
||||
$group['sport_id'] = $event['sport_id'];
|
||||
$group['provider_id'] = $event['provider_id'];
|
||||
$group['competition_group_id'] = $match->competition_group_id;
|
||||
$home['add_by_method_id'] = 1;
|
||||
$group['name'] = $event['group'];
|
||||
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $event['group_id']], $group);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,11 @@ class StoreElement
|
||||
|
||||
unset($ele['provider_element_id']);
|
||||
|
||||
$ele['add_by_method_id'] = 1;
|
||||
|
||||
$sport_id = $ele['sport_id'] ?? 0;
|
||||
|
||||
if (! isset($elements[$sport_id][$provider_element_id])) {
|
||||
if ($sport_id && ! isset($elements[$sport_id][$provider_element_id])) {
|
||||
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $provider_element_id], $ele);
|
||||
|
||||
|
||||
@@ -14,10 +14,11 @@ class StoreGroup
|
||||
|
||||
$sport_id = $group['sport_id'] ?? 0;
|
||||
|
||||
if (! isset($groups[$sport_id][$provider_group_id])) {
|
||||
$ele['add_by_method_id'] = 1;
|
||||
|
||||
if ($sport_id && ! isset($groups[$sport_id][$provider_group_id])) {
|
||||
|
||||
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $provider_group_id], $group);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use App\Models\Sport;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
@@ -41,7 +42,7 @@ class BettypesTable
|
||||
->label('Sport')
|
||||
->options(fn () => Sport::where('is_active', 1)->pluck('name', 'id')
|
||||
->toArray()),
|
||||
])
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->recordActions([
|
||||
EditAction::make()->hiddenLabel(),
|
||||
]);
|
||||
|
||||
@@ -16,13 +16,13 @@ class CompetitionGroupResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CompetitionGroup::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-list-numbers';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-folder';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = AdministratorCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Static Data';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Dynamic Data';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\CompetitionGroups\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class CompetitionGroupForm
|
||||
@@ -10,7 +11,8 @@ class CompetitionGroupForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,22 @@
|
||||
|
||||
namespace App\Filament\Resources\CompetitionGroups\Tables;
|
||||
|
||||
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\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\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CompetitionGroupsTable
|
||||
@@ -27,7 +40,8 @@ class CompetitionGroupsTable
|
||||
->color('gray')
|
||||
->label('Event')
|
||||
->icon(fn ($record) => $record->country->icon),
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
SelectColumn::make('level')
|
||||
->width(30)
|
||||
->options([
|
||||
@@ -35,6 +49,37 @@ class CompetitionGroupsTable
|
||||
'MEDIUM' => 'MEDIUM',
|
||||
'LOW' => 'LOW',
|
||||
]),
|
||||
])->filters([
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->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([
|
||||
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.'),
|
||||
),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CompetitonGroupProviders;
|
||||
|
||||
use App\Filament\Clusters\Administrator\AdministratorCluster;
|
||||
use App\Filament\Resources\CompetitonGroupProviders\Pages\ListCompetitonGroupProviders;
|
||||
use App\Filament\Resources\CompetitonGroupProviders\Schemas\CompetitonGroupProviderForm;
|
||||
use App\Filament\Resources\CompetitonGroupProviders\Tables\CompetitonGroupProvidersTable;
|
||||
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 $cluster = AdministratorCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Dynamic Data';
|
||||
|
||||
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\Resources\CompetitonGroupProviders\Pages;
|
||||
|
||||
use App\Filament\Resources\CompetitonGroupProviders\CompetitonGroupProviderResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCompetitonGroupProvider extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CompetitonGroupProviderResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CompetitonGroupProviders\Pages;
|
||||
|
||||
use App\Filament\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\Resources\CompetitonGroupProviders\Pages;
|
||||
|
||||
use App\Filament\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\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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CompetitonGroupProviders\Tables;
|
||||
|
||||
use App\Models\AddByMethod;
|
||||
use App\Models\Country;
|
||||
use App\Models\Provider;
|
||||
use App\Models\Sport;
|
||||
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
|
||||
->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('Event')
|
||||
->icon(fn ($record) => $record->competition_group->country->icon),
|
||||
TextColumn::make('competition_group.name')
|
||||
->searchable(),
|
||||
TextColumn::make('provider_group_id'),
|
||||
TextColumn::make('name')
|
||||
->label('Group name')
|
||||
->searchable(),
|
||||
TextColumn::make('add_by_method.name')
|
||||
->color(fn ($record) => $record->add_by_method->color)
|
||||
->icon(fn ($record) => $record->add_by_method->icon)
|
||||
->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([
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Group deleted')
|
||||
->body('The provider group has been deleted successfully.'),
|
||||
),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ElementProviders;
|
||||
|
||||
use App\Filament\Clusters\Administrator\AdministratorCluster;
|
||||
use App\Filament\Resources\ElementProviders\Pages\ListElementProviders;
|
||||
use App\Filament\Resources\ElementProviders\Schemas\ElementProviderForm;
|
||||
use App\Filament\Resources\ElementProviders\Tables\ElementProvidersTable;
|
||||
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 ?string $cluster = AdministratorCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Dynamic Data';
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ElementProviders\Pages;
|
||||
|
||||
use App\Filament\Resources\ElementProviders\ElementProviderResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateElementProvider extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ElementProviderResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ElementProviders\Pages;
|
||||
|
||||
use App\Filament\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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ElementProviders\Pages;
|
||||
|
||||
use App\Filament\Resources\ElementProviders\ElementProviderResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListElementProviders extends ListRecords
|
||||
{
|
||||
protected static string $resource = ElementProviderResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ElementProviders\Tables;
|
||||
|
||||
use App\Models\AddByMethod;
|
||||
use App\Models\Country;
|
||||
use App\Models\Sport;
|
||||
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
|
||||
->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('provider_element_id'),
|
||||
TextColumn::make('element_group.competition_group.name'),
|
||||
TextColumn::make('element.name')->label('TXOdds Name'),
|
||||
TextColumn::make('name')->label('Client Name'),
|
||||
TextColumn::make('add_by_method.name')
|
||||
->color(fn ($record) => $record->add_by_method->color)
|
||||
->icon(fn ($record) => $record->add_by_method->icon)
|
||||
->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('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([
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Element deleted')
|
||||
->body('The provider element has been deleted successfully.'),
|
||||
),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Elements;
|
||||
|
||||
use App\Filament\Clusters\Administrator\AdministratorCluster;
|
||||
use App\Filament\Resources\Elements\Pages\ListElements;
|
||||
use App\Filament\Resources\Elements\Schemas\ElementForm;
|
||||
use App\Filament\Resources\Elements\Tables\ElementsTable;
|
||||
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 = AdministratorCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Dynamic Data';
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Elements\Pages;
|
||||
|
||||
use App\Filament\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\Resources\Elements\Pages;
|
||||
|
||||
use App\Filament\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\Resources\Elements\Pages;
|
||||
|
||||
use App\Filament\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\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,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Elements\Tables;
|
||||
|
||||
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\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
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
|
||||
->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')
|
||||
->icon(fn ($record) => $record->country->icon),
|
||||
TextColumn::make('element_group.competition_group.name')->label('Competition Group'),
|
||||
// TextColumn::make('element_group.group.name')->label('Group'),
|
||||
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([
|
||||
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.'),
|
||||
),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class ProviderResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Provider::class;
|
||||
|
||||
protected static ?int $navigationSort = 23;
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-books';
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class SupervisorResource extends Resource
|
||||
|
||||
protected static ?string $cluster = AdministratorCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 20;
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Grapper';
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class TxoddsMarketResource extends Resource
|
||||
|
||||
protected static ?string $cluster = AdministratorCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 24;
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Grapper';
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ class StoreMapped
|
||||
$ele['sport_id'] = $event->sport_id;
|
||||
$ele['provider_id'] = Auth::user()->provider_id;
|
||||
$ele['element_id'] = $event->home_id ?? 0;
|
||||
$ele['add_by_method_id'] = 2;
|
||||
$ele['name'] = $mapper->home;
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper->home_id], $ele);
|
||||
|
||||
@@ -64,12 +65,14 @@ class StoreMapped
|
||||
$ele['sport_id'] = $event->sport_id;
|
||||
$ele['provider_id'] = Auth::user()->provider_id;
|
||||
$ele['element_id'] = $event->away_id ?? 0;
|
||||
$ele['add_by_method_id'] = 2;
|
||||
$ele['name'] = $mapper->away;
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper->away_id], $ele);
|
||||
|
||||
$group['sport_id'] = $event->sport_id;
|
||||
$group['provider_id'] = Auth::user()->provider_id;
|
||||
$group['competition_group_id'] = $event->competition_group_id;
|
||||
$group['add_by_method_id'] = 2;
|
||||
$group['name'] = $mapper->group;
|
||||
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $mapper->group_id], $group);
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AddByMethod extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -11,6 +11,7 @@ class CompetitionGroupProvider extends Model
|
||||
'competition_group_id',
|
||||
'provider_id',
|
||||
'provider_group_id',
|
||||
'add_by_method_id',
|
||||
'name',
|
||||
];
|
||||
|
||||
@@ -23,4 +24,14 @@ class CompetitionGroupProvider extends Model
|
||||
{
|
||||
return $this->belongsTo(Provider::class);
|
||||
}
|
||||
|
||||
public function sport()
|
||||
{
|
||||
return $this->belongsTo(Sport::class);
|
||||
}
|
||||
|
||||
public function add_by_method()
|
||||
{
|
||||
return $this->belongsTo(AddByMethod::class);
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,14 @@ class Element extends Model
|
||||
{
|
||||
return $this->belongsTo(Sport::class);
|
||||
}
|
||||
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo(Country::class);
|
||||
}
|
||||
|
||||
public function element_group()
|
||||
{
|
||||
return $this->belongsTo(ElementGroup::class, 'id', 'element_id');
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,19 @@ class ElementGroup extends Model
|
||||
'group_id',
|
||||
'competition_group_id',
|
||||
];
|
||||
|
||||
public function element()
|
||||
{
|
||||
return $this->belongsTo(Element::class);
|
||||
}
|
||||
|
||||
public function group()
|
||||
{
|
||||
return $this->belongsTo(Group::class);
|
||||
}
|
||||
|
||||
public function competition_group()
|
||||
{
|
||||
return $this->belongsTo(CompetitionGroup::class);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ class ElementProvider extends Model
|
||||
'element_id',
|
||||
'provider_id',
|
||||
'provider_element_id',
|
||||
'add_by_method_id',
|
||||
'name',
|
||||
];
|
||||
|
||||
@@ -20,6 +21,11 @@ class ElementProvider extends Model
|
||||
return $this->belongsTo(Sport::class);
|
||||
}
|
||||
|
||||
public function element_group()
|
||||
{
|
||||
return $this->belongsTo(ElementGroup::class, 'element_id', 'element_id');
|
||||
}
|
||||
|
||||
public function element()
|
||||
{
|
||||
return $this->belongsTo(Element::class);
|
||||
@@ -29,4 +35,9 @@ class ElementProvider extends Model
|
||||
{
|
||||
return $this->belongsTo(Provider::class);
|
||||
}
|
||||
|
||||
public function add_by_method()
|
||||
{
|
||||
return $this->belongsTo(AddByMethod::class);
|
||||
}
|
||||
}
|
||||
Generated
+6
-6
@@ -11951,16 +11951,16 @@
|
||||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
"version": "2.3.6",
|
||||
"version": "2.3.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rectorphp/rector.git",
|
||||
"reference": "ca9ebb81d280cd362ea39474dabd42679e32ca6b"
|
||||
"reference": "9c46ad17f57963932c9788fd1b0f1d07ff450370"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/ca9ebb81d280cd362ea39474dabd42679e32ca6b",
|
||||
"reference": "ca9ebb81d280cd362ea39474dabd42679e32ca6b",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/9c46ad17f57963932c9788fd1b0f1d07ff450370",
|
||||
"reference": "9c46ad17f57963932c9788fd1b0f1d07ff450370",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -11999,7 +11999,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/rectorphp/rector/issues",
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.3.6"
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.3.7"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -12007,7 +12007,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-02-06T14:25:06+00:00"
|
||||
"time": "2026-02-19T14:44:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
||||
@@ -17,6 +17,7 @@ return new class extends Migration
|
||||
$table->integer('element_id')->index()->references('id')->on('elements');
|
||||
$table->integer('provider_id')->default(0)->nullable()->index()->references('id')->on('providers');
|
||||
$table->integer('provider_element_id')->index();
|
||||
$table->integer('add_by_method_id')->default(0)->nullable()->index();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ return new class extends Migration
|
||||
$table->integer('competition_group_id')->default(0)->nullable()->index()->references('id')->on('competition_groups');
|
||||
$table->integer('provider_id')->default(0)->nullable()->index()->references('id')->on('providers');
|
||||
$table->integer('provider_group_id')->default(0)->nullable()->index();
|
||||
$table->integer('add_by_method_id')->default(0)->nullable()->index();
|
||||
$table->string('name')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('add_by_methods', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('color');
|
||||
$table->string('icon');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('add_by_methods');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AddByMethodSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
/**
|
||||
* add_by_methods
|
||||
*/
|
||||
$sql = "INSERT INTO `add_by_methods` (`id`, `name`, `color`, `icon`, `created_at`, `updated_at`)
|
||||
VALUES
|
||||
(1, 'Grapper', 'primary', 'phosphor-download-simple', NULL, NULL),
|
||||
(2, 'Manual', 'success', 'phosphor-user', NULL, NULL),
|
||||
(3, 'DB Mapper', 'warning', 'phosphor-gear', NULL, NULL);
|
||||
";
|
||||
DB::unprepared($sql);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ class DatabaseSeeder extends Seeder
|
||||
OddsTableSeeder::class,
|
||||
AlarmLevelSeeder::class,
|
||||
OddsNameSeeder::class,
|
||||
AddByMethodSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user