double players
This commit is contained in:
1 parent
fd7b8fadad
commit
11189ec3d6
3 files changed
+19
-22
No files matched your search
+15
-18
@@ -4,6 +4,7 @@ namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Tables;
|
||||
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
@@ -18,7 +19,6 @@ class StatistikoPlayersTable
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
// ->poll()
|
||||
->columns([
|
||||
TextColumn::make('match_id')->searchable(),
|
||||
TextColumn::make('details.name')
|
||||
@@ -31,28 +31,24 @@ class StatistikoPlayersTable
|
||||
TextColumn::make('event.away.name')->searchable()->color('success'),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('event_filters')
|
||||
Filter::make('player_filters')
|
||||
->schema([
|
||||
Checkbox::make('find_double'),
|
||||
])->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['find_double'],
|
||||
function (Builder $query) use ($data) {
|
||||
function (Builder $query) {
|
||||
$arr = [];
|
||||
// $events = StatistikoPlayer::query()->select('match_id', 'ss_player_id')->get()->toArray();
|
||||
// foreach ($events as $value) {
|
||||
// $match_id = $value['match_id'];
|
||||
// $ss_player_id = $value['ss_player_id'];
|
||||
// if (in_array($ss_player_id, $arr[$value['match_id']]))
|
||||
// $arr[$value['match_id']][] = $value['ss_player_id'];
|
||||
// }
|
||||
// dd($arr);
|
||||
// dd($events);
|
||||
// $doublEvents = array_diff_assoc(
|
||||
// $events,
|
||||
// array_unique($events)
|
||||
// );
|
||||
// $query->whereIn('match_id', $doublEvents)->orderBy('match_id');
|
||||
$events = StatistikoPlayer::query()->select('match_id', 'ss_player_id')->get()->toArray();
|
||||
foreach ($events as $value) {
|
||||
$match_id = $value['match_id'];
|
||||
$player_id = $value['ss_player_id'];
|
||||
|
||||
if (isset($arr[$match_id]) && in_array($player_id, $arr[$match_id])) {
|
||||
return $query->where('match_id', $match_id)->where('ss_player_id', $player_id);
|
||||
}
|
||||
$arr[$match_id][] = $player_id;
|
||||
}
|
||||
}
|
||||
);
|
||||
})->indicateUsing(function (array $data): ?string {
|
||||
@@ -65,7 +61,8 @@ class StatistikoPlayersTable
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
EditAction::make()->iconButton(),
|
||||
DeleteAction::make()->iconButton(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
|
||||
Reference in new issue
Block a user