wip
This commit is contained in:
1 parent
7e0b74d79c
commit
f9c0c5aec5
2 files changed
+33
-11
No files matched your search
@@ -17,6 +17,7 @@ use Filament\Notifications\Notification;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
/**
|
||||
@@ -710,7 +711,7 @@ class PlayerPropsDrop extends Widget
|
||||
|
||||
$id_used = [];
|
||||
|
||||
foreach ($places as $k => $place) {
|
||||
foreach ($places as $place) {
|
||||
$this->getPlayerForPosition($lineup, $id_used, $place, $players);
|
||||
}
|
||||
|
||||
@@ -808,6 +809,7 @@ class PlayerPropsDrop extends Widget
|
||||
|
||||
public function getPlayerForPosition(array &$lineup, array &$id_used, int $place, Collection $players)
|
||||
{
|
||||
$log = false;
|
||||
$position = $this->activeBoxes[$place];
|
||||
|
||||
$hirarchy = PositionHirarchie::load();
|
||||
@@ -815,26 +817,46 @@ class PlayerPropsDrop extends Widget
|
||||
$fitered = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
|
||||
if ($log) {
|
||||
Log::debug("A $place - $position", $fitered);
|
||||
}
|
||||
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
} else {
|
||||
if (isset($hirarchy[$position])) {
|
||||
$position = $hirarchy[$position][0];
|
||||
$fitered = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
$position2 = $hirarchy[$position][0];
|
||||
$fitered = $players->where('pos', $position2)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position2];
|
||||
$id_used[] = $fitered['id'];
|
||||
if ($log) {
|
||||
Log::debug("B $place - $position $position2", $fitered);
|
||||
}
|
||||
|
||||
} elseif (isset($hirarchy[$position][1])) {
|
||||
$position = $hirarchy[$position][1];
|
||||
$fitered = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
$position3 = $hirarchy[$position][1];
|
||||
$fitered = $players->where('pos', $position3)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
if ($log) {
|
||||
Log::debug("C $place - $position $position2 $position3", $fitered);
|
||||
}
|
||||
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position3];
|
||||
$id_used[] = $fitered['id'];
|
||||
} elseif (isset($hirarchy[$position][2])) {
|
||||
$position = $hirarchy[$position][2];
|
||||
$fitered = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
$position4 = $hirarchy[$position][2];
|
||||
$fitered = $players->where('pos', $position4)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
if ($log) {
|
||||
Log::debug("D $place - $position $position2 $position3 $position4", $fitered);
|
||||
}
|
||||
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position4];
|
||||
$id_used[] = $fitered['id'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class PlayerPropsTable extends TableWidget
|
||||
->emptyStateHeading('No team selected')
|
||||
->columns([
|
||||
ViewColumn::make('drag_card')
|
||||
->label(fn() => $this->getHeadingTable())
|
||||
->label(fn () => $this->getHeadingTable())
|
||||
->view('filament.tables.columns.drag-card'),
|
||||
])->extraAttributes([
|
||||
'id' => 'playerdragtable',
|
||||
|
||||
Reference in new issue
Block a user