move all into clusters
This commit is contained in:
1 parent
7ff3fbadb6
commit
a980ea92ce
91 files changed
+300
-262
No files matched your search
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\DynamicData;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
|
||||
class DynamicDataCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-atom';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\DynamicData\Resources\CompetitionGroups;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\DynamicDataCluster;
|
||||
use App\Filament\Clusters\DynamicData\Resources\CompetitionGroups\Pages\ListCompetitionGroups;
|
||||
use App\Filament\Clusters\DynamicData\Resources\CompetitionGroups\Schemas\CompetitionGroupForm;
|
||||
use App\Filament\Clusters\DynamicData\Resources\CompetitionGroups\Tables\CompetitionGroupsTable;
|
||||
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 = DynamicDataCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'TxOdds';
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\DynamicData\Resources\CompetitionGroups\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\Resources\CompetitionGroups\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\Resources\CompetitionGroups\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\DynamicData\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
|
||||
{
|
||||
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('Event')
|
||||
->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')
|
||||
->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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\DynamicData\Resources\CompetitonGroupProviders;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\DynamicDataCluster;
|
||||
use App\Filament\Clusters\DynamicData\Resources\CompetitonGroupProviders\Pages\ListCompetitonGroupProviders;
|
||||
use App\Filament\Clusters\DynamicData\Resources\CompetitonGroupProviders\Schemas\CompetitonGroupProviderForm;
|
||||
use App\Filament\Clusters\DynamicData\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 = DynamicDataCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Provider Relations';
|
||||
|
||||
protected static ?string $navigationLabel = '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\DynamicData\Resources\CompetitonGroupProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\Resources\CompetitonGroupProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\Resources\CompetitonGroupProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\DynamicData\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')->label('PrId')->alignCenter(),
|
||||
TextColumn::make('id')->label('TxId')->alignCenter(),
|
||||
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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\DynamicData\Resources\ElementProviders;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\DynamicDataCluster;
|
||||
use App\Filament\Clusters\DynamicData\Resources\ElementProviders\Pages\ListElementProviders;
|
||||
use App\Filament\Clusters\DynamicData\Resources\ElementProviders\Schemas\ElementProviderForm;
|
||||
use App\Filament\Clusters\DynamicData\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 = DynamicDataCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Provider Relations';
|
||||
|
||||
protected static ?string $navigationLabel = '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\DynamicData\Resources\ElementProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\Resources\ElementProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\Resources\ElementProviders\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\DynamicData\Resources\ElementProviders\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\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('id')->label('TxId')->alignCenter(),
|
||||
TextColumn::make('provider_element_id')->label('PrId')->alignCenter(),
|
||||
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('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([
|
||||
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\Clusters\DynamicData\Resources\Elements;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\DynamicDataCluster;
|
||||
use App\Filament\Clusters\DynamicData\Resources\Elements\Pages\ListElements;
|
||||
use App\Filament\Clusters\DynamicData\Resources\Elements\Schemas\ElementForm;
|
||||
use App\Filament\Clusters\DynamicData\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 = DynamicDataCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'TxOdds';
|
||||
|
||||
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\Clusters\DynamicData\Resources\Elements\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\Resources\Elements\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\Resources\Elements\Pages;
|
||||
|
||||
use App\Filament\Clusters\DynamicData\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\DynamicData\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\Clusters\DynamicData\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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Administrator;
|
||||
namespace App\Filament\Clusters\Grapper;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
|
||||
class AdministratorCluster extends Cluster
|
||||
class GrapperCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-atom';
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?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);
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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\Tables\SupervisorsTable;
|
||||
use App\Filament\Resources\Supervisors\Schemas\SupervisorForm;
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
<?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\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('10s')
|
||||
->columns([
|
||||
Split::make([
|
||||
TextColumn::make('id')->badge()->alignCenter(),
|
||||
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 $livewire->tableFilters['provider_id']['value'] == 8;
|
||||
})
|
||||
->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',
|
||||
];
|
||||
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',
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}),
|
||||
SelectColumn::make('sport_id')
|
||||
->hidden(function (ListSupervisors $livewire) {
|
||||
return $livewire->tableFilters['provider_id']['value'] == 11;
|
||||
})
|
||||
->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]);
|
||||
}),
|
||||
TextInputColumn::make('days_to')->prefix('Days To')
|
||||
->hidden(function (ListSupervisors $livewire) {
|
||||
return in_array($livewire->tableFilters['provider_id']['value'], [7, 8, 11]);
|
||||
}),
|
||||
])->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'),
|
||||
TextInputColumn::make('commandline_options')->prefix('Bash')
|
||||
->tooltip('command used in supervisor script')
|
||||
->hidden(function (ListSupervisors $livewire) {
|
||||
return $livewire->tableFilters['provider_id']['value'] == 8;
|
||||
}),
|
||||
])->space(3),
|
||||
SelectColumn::make('is_supervisor')
|
||||
->allowOptionsHtml()
|
||||
->native(false)
|
||||
->options([
|
||||
'0' => '<span class="text-amber-500">Cronjob</span>',
|
||||
'1' => '<span class="text-blue-500">Supervisor</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')
|
||||
->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)
|
||||
->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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Bettypes;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Bettypes\Pages\ListBettypes;
|
||||
use App\Filament\Clusters\StaticData\Resources\Bettypes\Schemas\BettypeForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\Bettypes\Tables\BettypesTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\Bettype;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BettypeResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Bettype::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-storefront';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'NuhOdds Markets';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return BettypeForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return BettypesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBettypes::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Bettypes\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Bettypes\BettypeResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBettype extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BettypeResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Bettypes\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Bettypes\BettypeResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditBettype extends EditRecord
|
||||
{
|
||||
protected static string $resource = BettypeResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Bettypes\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Bettypes\BettypeResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBettypes extends ListRecords
|
||||
{
|
||||
protected static string $resource = BettypeResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Bettypes\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class BettypeForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Bettypes\Tables;
|
||||
|
||||
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;
|
||||
|
||||
class BettypesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->recordAction(null)
|
||||
->columns([
|
||||
TextColumn::make('bettype_id')
|
||||
->width('1rem')
|
||||
->searchable()->label('Id'),
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->width('1rem')
|
||||
->icon(function ($record): string {
|
||||
return $record->sport->icon;
|
||||
}),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('name')->searchable(),
|
||||
IconColumn::make('ft')->boolean()->trueIcon('phosphor-check-circle-fill')->falseIcon('phosphor-circle')->falseColor('gray'),
|
||||
IconColumn::make('ht')->boolean()->trueIcon('phosphor-check-circle-fill')->falseIcon('phosphor-circle')->falseColor('gray'),
|
||||
IconColumn::make('h2')->boolean()->trueIcon('phosphor-check-circle-fill')->falseIcon('phosphor-circle')->falseColor('gray'),
|
||||
IconColumn::make('co')->boolean()->trueIcon('phosphor-check-circle-fill')->falseIcon('phosphor-circle')->falseColor('gray'),
|
||||
IconColumn::make('q1')->boolean()->trueIcon('phosphor-check-circle-fill')->falseIcon('phosphor-circle')->falseColor('gray'),
|
||||
IconColumn::make('p1')->boolean()->trueIcon('phosphor-check-circle-fill')->falseIcon('phosphor-circle')->falseColor('gray'),
|
||||
IconColumn::make('q1')->boolean()->trueIcon('phosphor-check-circle-fill')->falseIcon('phosphor-circle')->falseColor('gray'),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->options(fn () => Sport::where('is_active', 1)->pluck('name', 'id')
|
||||
->toArray()),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->recordActions([
|
||||
EditAction::make()->hiddenLabel(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Countries;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Countries\Pages\ManageCountries;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\Country;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CountryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Country::class;
|
||||
|
||||
protected static ?int $navigationSort = 22;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-flag';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')->required(),
|
||||
TextInput::make('icon'),
|
||||
TextInput::make('iso2')->maxLength(2),
|
||||
TextInput::make('iso3')->maxLength(3),
|
||||
TextInput::make('cc'),
|
||||
TextInput::make('numeric'),
|
||||
Toggle::make('is_country'),
|
||||
Toggle::make('disabled')->label('Disable')->aboveLabel(['Hide in this table']),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->recordAction(null)
|
||||
->recordTitleAttribute('name')
|
||||
->columns([
|
||||
TextColumn::make('id')->searchable(),
|
||||
IconColumn::make('icon')
|
||||
->sortable()
|
||||
->icon(function ($state): string {
|
||||
return $state;
|
||||
})->label('Flags')->size(IconSize::TwoExtraLarge),
|
||||
TextColumn::make('name')
|
||||
->searchable()
|
||||
->copyable()
|
||||
->copyMessage('Name copied')
|
||||
->copyMessageDuration(1500),
|
||||
// TextColumn::make('iso2'),
|
||||
TextColumn::make('iso3'),
|
||||
TextColumn::make('cc'),
|
||||
TextColumn::make('numeric'),
|
||||
IconColumn::make('is_country')->alignCenter()->boolean(),
|
||||
|
||||
])
|
||||
->defaultSort('name', direction: 'asc')
|
||||
->filters([
|
||||
TernaryFilter::make('is_country'),
|
||||
|
||||
Filter::make('icon')
|
||||
->label('Missing Icons')
|
||||
->query(fn (Builder $query): Builder => $query->whereNull('icon')),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->hiddenLabel(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->where('disabled', false)->count();
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('disabled', false);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageCountries::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Countries\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Countries\CountryResource;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageCountries extends ManageRecords
|
||||
{
|
||||
protected static string $resource = CountryResource::class;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Sports\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Sports\SportResource;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageSports extends ManageRecords
|
||||
{
|
||||
protected static string $resource = SportResource::class;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\Sports;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\Sports\Pages\ManageSports;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\Sport;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class SportResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Sport::class;
|
||||
|
||||
protected static ?int $navigationSort = 24;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-volleyball';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('icon')
|
||||
->label('')
|
||||
->size(IconSize::TwoExtraLarge)
|
||||
->icon(function ($record): string {
|
||||
return $record->icon;
|
||||
}),
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('bapi')->alignCenter()->label('Betsapi'),
|
||||
TextColumn::make('bwin')->alignCenter()->label('Bwin'),
|
||||
TextColumn::make('b365')->alignCenter()->label('Bet365'),
|
||||
TextColumn::make('logi')->alignCenter()->label('Logifuture'),
|
||||
TextColumn::make('magl')->alignCenter()->label('Magloo'),
|
||||
ToggleColumn::make('is_active'),
|
||||
])
|
||||
->filters([
|
||||
TernaryFilter::make('is_active')->default(true),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageSports::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\TxoddsMarketResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTxoddsMarket extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TxoddsMarketResource::class;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\TxoddsMarketResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTxoddsMarket extends EditRecord
|
||||
{
|
||||
protected static string $resource = TxoddsMarketResource::class;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\TxoddsMarketResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTxoddsMarkets extends ListRecords
|
||||
{
|
||||
protected static string $resource = TxoddsMarketResource::class;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TxoddsMarketForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Tables;
|
||||
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TxoddsMarketsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('market_id')->badge()->searchable(),
|
||||
TextColumn::make('name')->searchable(),
|
||||
ToggleColumn::make('soccer')->toggleable(isToggledHiddenByDefault: true),
|
||||
ToggleColumn::make('ice_hockey')->toggleable(isToggledHiddenByDefault: true),
|
||||
ToggleColumn::make('basketball')->toggleable(isToggledHiddenByDefault: true),
|
||||
ToggleColumn::make('tennis')->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('sport_market')
|
||||
->schema([
|
||||
Select::make(name: 'sport_market')
|
||||
->placeholder('Filter Sport')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->preload()
|
||||
->options(function () {
|
||||
return [
|
||||
'soccer' => 'Soccer',
|
||||
'ice_hockey' => 'Ice Hockey',
|
||||
'basketball' => 'Basketball',
|
||||
'tennis' => 'Tennis',
|
||||
];
|
||||
})
|
||||
->live(),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['sport_market'],
|
||||
fn (Builder $query, $sport_market) => $query->where($sport_market, 1)
|
||||
);
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferColumnManager(false)
|
||||
->deferFilters(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\TxoddsMarkets;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Pages\ListTxoddsMarkets;
|
||||
use App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Schemas\TxoddsMarketForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\TxoddsMarkets\Tables\TxoddsMarketsTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\TxoddsMarket;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TxoddsMarketResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TxoddsMarket::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-storefront';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TxoddsMarketForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TxoddsMarketsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTxoddsMarkets::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
|
||||
class StaticDataCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-atom';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Clients\Pages\ListClients;
|
||||
use App\Filament\Clusters\User\Resources\Clients\Schemas\ClientForm;
|
||||
use App\Filament\Clusters\User\Resources\Clients\Tables\ClientsTable;
|
||||
use App\Filament\Clusters\User\UserCluster;
|
||||
use App\Models\Client;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ClientResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Client::class;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-baseball-helmet';
|
||||
|
||||
protected static ?string $cluster = UserCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'User';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ClientForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ClientsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListClients::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Clients\ClientResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateClient extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ClientResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Clients\ClientResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditClient extends EditRecord
|
||||
{
|
||||
protected static string $resource = ClientResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Clients\ClientResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListClients extends ListRecords
|
||||
{
|
||||
protected static string $resource = ClientResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Schemas;
|
||||
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\Provider;
|
||||
use App\Models\Sport;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ClientForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
TextInput::make('homepage')
|
||||
->default(null),
|
||||
Select::make('bookmaker')
|
||||
->options(Bookmaker::query()->pluck('name', 'id'))
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
Select::make('provider')
|
||||
->options(Provider::query()->pluck('name', 'id'))
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
Select::make('sport')
|
||||
->options(Sport::query()->pluck('name', 'id'))
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Clients\Tables;
|
||||
|
||||
use App\Actions\SettingGeneratorClient;
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\Provider;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ClientsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->recordAction(null)
|
||||
->columns([
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('bookmaker')
|
||||
->wrap()
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state): string => Bookmaker::where('id', $state)->pluck('name')->first()),
|
||||
TextColumn::make('provider')
|
||||
->badge()
|
||||
->wrap()
|
||||
->color('success')
|
||||
->formatStateUsing(fn (string $state): string => Provider::where('id', $state)->pluck('name')->first()),
|
||||
TextColumn::make('sport')
|
||||
->badge()
|
||||
->wrap()
|
||||
->color('warning')
|
||||
->formatStateUsing(fn (string $state): string => Sport::where('id', $state)->pluck('name')->first()),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('Create Settings')
|
||||
->icon('phosphor-gear-fine')
|
||||
->tooltip('Generates basic configuration for client')
|
||||
->action(function ($record) {
|
||||
SettingGeneratorClient::run($record);
|
||||
}),
|
||||
EditAction::make()->hiddenLabel(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\MultilineSettings;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\MultilineSettings\Pages\ListMultilineSettings;
|
||||
use App\Filament\Clusters\User\Resources\MultilineSettings\Schemas\MultilineSettingForm;
|
||||
use App\Filament\Clusters\User\Resources\MultilineSettings\Tables\MultilineSettingsTable;
|
||||
use App\Filament\Clusters\User\UserCluster;
|
||||
use App\Models\MultilineSetting;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class MultilineSettingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = MultilineSetting::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::Bars3;
|
||||
|
||||
protected static ?string $cluster = UserCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'User';
|
||||
|
||||
protected static ?int $navigationSort = 30;
|
||||
|
||||
protected static ?string $navigationLabel = 'Multiline';
|
||||
|
||||
// protected static ?string $modelLabel = 'Group';
|
||||
|
||||
// protected static ?string $title = 'Group';
|
||||
|
||||
// protected static ?string $pluralModelLabel = 'Groups';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return MultilineSettingForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return MultilineSettingsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListMultilineSettings::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\MultilineSettings\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\MultilineSettings\MultilineSettingResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateMultilineSetting extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MultilineSettingResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\MultilineSettings\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\MultilineSettings\MultilineSettingResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditMultilineSetting extends EditRecord
|
||||
{
|
||||
protected static string $resource = MultilineSettingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\MultilineSettings\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\MultilineSettings\MultilineSettingResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMultilineSettings extends ListRecords
|
||||
{
|
||||
protected static string $resource = MultilineSettingResource::class;
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\MultilineSettings\Schemas;
|
||||
|
||||
use App\Models\Sport;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class MultilineSettingForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')->required(),
|
||||
TextInput::make('short')->required(),
|
||||
TextInput::make('table')->required(),
|
||||
Select::make('sport_id')
|
||||
->required()
|
||||
->label('Sport')
|
||||
->options(fn () => Sport::where('is_active', 1)->pluck('name', 'id')
|
||||
->toArray()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\MultilineSettings\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
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;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class MultilineSettingsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->description('Order of bettypes display in monitor')
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->width('1rem')
|
||||
->icon(function ($record): string {
|
||||
return $record->sport->icon;
|
||||
}),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('short'),
|
||||
TextColumn::make('table'),
|
||||
TextColumn::make('rows'),
|
||||
TextColumn::make('sorting')->alignCenter()->badge(),
|
||||
])
|
||||
->reorderable('sorting')
|
||||
->deferFilters(false)
|
||||
->filters([
|
||||
SelectFilter::make('sport_id')
|
||||
->label('Sport')
|
||||
->default(1)
|
||||
->selectablePlaceholder(false)
|
||||
->relationship('sport', 'name', fn (Builder $query) => $query->where('is_active', 1))
|
||||
->preload(),
|
||||
], FiltersLayout::AboveContent)
|
||||
->hiddenFilterIndicators()
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\UserActivities\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\UserActivities\UserActivityResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUserActivity extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserActivityResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\UserActivities\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\UserActivities\UserActivityResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditUserActivity extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserActivityResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\UserActivities\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\UserActivities\UserActivityResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUserActivities extends ListRecords
|
||||
{
|
||||
protected static string $resource = UserActivityResource::class;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\UserActivities\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class UserActivityForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\UserActivities\Tables;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\UserActivity;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class UserActivitiesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->headerActions([
|
||||
Action::make('tuncate_table')->action(function () {
|
||||
UserActivity::truncate();
|
||||
|
||||
Notification::make()
|
||||
->title('Tuncated table successfully')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
])
|
||||
->columns([
|
||||
TextColumn::make('user.name'),
|
||||
TextColumn::make('ip'),
|
||||
TextColumn::make('country'),
|
||||
TextColumn::make('location'),
|
||||
TextColumn::make('created_at')->dateTime('M j, Y H:i'),
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
->deferFilters(false)
|
||||
->hiddenFilterIndicators(false)
|
||||
->persistFiltersInSession()
|
||||
->filters([
|
||||
Filter::make('created_at')
|
||||
->columns(2)->columnSpan(3)
|
||||
->schema([
|
||||
Toggle::make('user_latest')
|
||||
->onIcon('phosphor-user-fill')
|
||||
->offIcon('phosphor-user')
|
||||
->label('Logged User'),
|
||||
Select::make(name: 'user_id')
|
||||
->hidden(fn () => auth()->user()->sport_id == 5)
|
||||
->placeholder('User')
|
||||
->prefixIcon('phosphor-user')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function () {
|
||||
$res = UserActivity::groupBy('user_id')->pluck('user_id')->toArray();
|
||||
|
||||
return User::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
})
|
||||
->live(),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['user_latest'],
|
||||
function (Builder $query) {
|
||||
$res = UserActivity::query()
|
||||
->whereIn('id', function ($q) {
|
||||
$q->select(DB::raw('MAX(id) FROM user_activities GROUP BY user_id'));
|
||||
})
|
||||
->pluck('id');
|
||||
$query->whereIn('id', $res);
|
||||
}
|
||||
)
|
||||
->when(
|
||||
$data['user_id'],
|
||||
fn (Builder $query, $user_id): Builder => $query->where('user_id', $user_id)->orderBy('created_at', 'DESC'),
|
||||
);
|
||||
})->indicateUsing(function (array $data): array {
|
||||
$indicators = [];
|
||||
if ($data['user_latest'] ?? null) {
|
||||
$indicators[] = Indicator::make('User latest')->color('info');
|
||||
}
|
||||
if ($data['user_id'] ?? null) {
|
||||
$user = User::query()->whereIn('id', $data['user_id'])->value('name');
|
||||
$indicators[] = Indicator::make($user)->color('info');
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\UserActivities;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\UserActivities\Pages\ListUserActivities;
|
||||
use App\Filament\Clusters\User\Resources\UserActivities\Schemas\UserActivityForm;
|
||||
use App\Filament\Clusters\User\Resources\UserActivities\Tables\UserActivitiesTable;
|
||||
use App\Filament\Clusters\User\UserCluster;
|
||||
use App\Models\UserActivity;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UserActivityResource extends Resource
|
||||
{
|
||||
protected static ?string $model = UserActivity::class;
|
||||
|
||||
protected static ?string $cluster = UserCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 20;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'User';
|
||||
|
||||
protected static ?string $navigationLabel = 'Connected';
|
||||
|
||||
protected static ?string $modelLabel = '';
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-users';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return UserActivityForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return UserActivitiesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListUserActivities::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return (string) UserActivity::query()
|
||||
->select('user_id', \DB::raw('count(*) as total'))
|
||||
->groupBy('user_id')
|
||||
->pluck('user_id')
|
||||
->first() ?? 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Users\UserResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Users\UserResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditUser extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Users\UserResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUsers extends ListRecords
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Users\Schemas;
|
||||
|
||||
use App\Models\Bookmaker;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class UserForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Hidden::make('email_verified_at')->default(now()),
|
||||
Section::make('User Details')
|
||||
->columnSpanFull()
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->columns(1)
|
||||
->required(),
|
||||
TextInput::make('email')
|
||||
->label('Email address')
|
||||
->email()
|
||||
->required(),
|
||||
TextInput::make('password')
|
||||
->password()
|
||||
->revealable()
|
||||
->dehydrated(fn ($state): bool => filled($state))
|
||||
->dehydrateStateUsing(fn ($state): string => Hash::make($state))
|
||||
->same('password_confirmation')
|
||||
->rule(Password::min(8)
|
||||
->mixedCase()
|
||||
->numbers()
|
||||
->symbols()
|
||||
->uncompromised())
|
||||
->label('Password'),
|
||||
TextInput::make('password_confirmation')
|
||||
->password()
|
||||
->dehydrated(false)
|
||||
->same('password')
|
||||
->revealable(),
|
||||
]),
|
||||
Section::make('Bookmaker Configuration')
|
||||
->columnSpanFull()
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('client_id')
|
||||
->relationship('client', 'name')
|
||||
->preload(),
|
||||
Select::make('provider_id')
|
||||
->relationship('provider', 'name')
|
||||
->preload(),
|
||||
Select::make('bookmaker_id')
|
||||
->label('Active Bookmaker')
|
||||
->options(fn () => Bookmaker::query()->where('is_client', 1)->pluck('name', 'id'))
|
||||
->preload(),
|
||||
Select::make('partner_bookmaker_id')
|
||||
->label('Partner Bookmaker')
|
||||
->options(fn () => Bookmaker::query()->where('is_client', 1)->pluck('name', 'id'))
|
||||
->preload(),
|
||||
]),
|
||||
Section::make('Authorisations')
|
||||
->visible(fn () => auth()->user()->hasRole('super_admin'))
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
Select::make('roles')
|
||||
->label('Rollen')
|
||||
->prefixIcon('phosphor-gear')
|
||||
->aboveContent('Only visible for super_admin')
|
||||
->visible(fn () => auth()->user()->hasRole('super_admin'))
|
||||
->relationship('roles', 'name')
|
||||
->multiple()
|
||||
->preload()
|
||||
->searchable(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Users\Tables;
|
||||
|
||||
use App\Actions\SettingGeneratorUser;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UsersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->recordAction(null)
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('email')
|
||||
->label('Email address')
|
||||
->searchable(),
|
||||
TextColumn::make('client.name')->badge(),
|
||||
TextColumn::make('roles.name')->badge()->color('success')->wrap(),
|
||||
TextColumn::make('bookmaker.name')
|
||||
->label('Active Bookmaker')
|
||||
->badge()
|
||||
->color('warning'),
|
||||
TextColumn::make('partnerbookmaker.name')
|
||||
->label('Partner Bookmaker')
|
||||
->badge()
|
||||
->color('warning'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('Create Settings')
|
||||
->icon('phosphor-gear-fine')
|
||||
->tooltip('Generates basic configuration for this user')
|
||||
->action(function ($record) {
|
||||
SettingGeneratorUser::run($record);
|
||||
}),
|
||||
EditAction::make()->hiddenLabel(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User\Resources\Users;
|
||||
|
||||
use App\Filament\Clusters\User\Resources\Users\Pages\ListUsers;
|
||||
use App\Filament\Clusters\User\Resources\Users\Schemas\UserForm;
|
||||
use App\Filament\Clusters\User\Resources\Users\Tables\UsersTable;
|
||||
use App\Filament\Clusters\User\UserCluster;
|
||||
use App\Models\User;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UserResource extends Resource
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-user';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = UserCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'User';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return UserForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return UsersTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListUsers::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\User;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
|
||||
class UserCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-atom';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
}
|
||||
Reference in new issue
Block a user