wip
This commit is contained in:
1 parent
e7ddd8049b
commit
15ec42c41a
1 file changed
+11
-68
@@ -15,6 +15,7 @@ use App\Models\SsLineupMemory;
|
||||
use App\Models\StatisticFixtures;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
@@ -684,8 +685,9 @@ class PlayerPropsDrop extends Widget
|
||||
if ($value?->details->position ?? 0) {
|
||||
$arr->push([
|
||||
'id' => $value->ss_player_id,
|
||||
'min' => $value->total_min,
|
||||
'min' => $value->average_min,
|
||||
'pos' => $value->details->position,
|
||||
'name' => $value->details->player_name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -699,8 +701,6 @@ class PlayerPropsDrop extends Widget
|
||||
|
||||
$players = $this->prepareLineUp();
|
||||
|
||||
$hirarchy = PositionHirarchie::load();
|
||||
|
||||
$places = LineUpMap::get($this->activeLineUp);
|
||||
|
||||
$lineup = [];
|
||||
@@ -708,38 +708,7 @@ class PlayerPropsDrop extends Widget
|
||||
$id_used = [];
|
||||
|
||||
foreach ($places as $k => $place) {
|
||||
|
||||
$position = $this->activeBoxes[$place];
|
||||
|
||||
$player = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($player['id'])) {
|
||||
$lineup[$player['id']] = ['id' => $player['id'], 'min' => $player['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $player['id'];
|
||||
} else {
|
||||
if (isset($hirarchy[$position])) {
|
||||
$position = $hirarchy[$position][0];
|
||||
$player = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
if (isset($player['id'])) {
|
||||
$lineup[$player['id']] = ['id' => $player['id'], 'min' => $player['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $player['id'];
|
||||
} elseif (isset($hirarchy[$position][1])) {
|
||||
$position = $hirarchy[$position][1];
|
||||
$player = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
if (isset($player['id'])) {
|
||||
$lineup[$player['id']] = ['id' => $player['id'], 'min' => $player['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $player['id'];
|
||||
} elseif (isset($hirarchy[$position][2])) {
|
||||
$position = $hirarchy[$position][2];
|
||||
$player = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
if (isset($player['id'])) {
|
||||
$lineup[$player['id']] = ['id' => $player['id'], 'min' => $player['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $player['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->getPlayerForPosition($lineup, $id_used, $place, $players);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 35; $i++) {
|
||||
@@ -815,38 +784,7 @@ class PlayerPropsDrop extends Widget
|
||||
$id_used = [];
|
||||
|
||||
foreach ($formation_positions as $place) {
|
||||
|
||||
$position = $this->activeBoxes[$place];
|
||||
|
||||
$player = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($player['id'])) {
|
||||
$lineup[$player['id']] = ['id' => $player['id'], 'min' => $player['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $player['id'];
|
||||
} else {
|
||||
if (isset($hirarchy[$position])) {
|
||||
$position = $hirarchy[$position][0];
|
||||
$player = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
if (isset($player['id'])) {
|
||||
$lineup[$player['id']] = ['id' => $player['id'], 'min' => $player['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $player['id'];
|
||||
} elseif (isset($hirarchy[$position][1])) {
|
||||
$position = $hirarchy[$position][1];
|
||||
$player = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
if (isset($player['id'])) {
|
||||
$lineup[$player['id']] = ['id' => $player['id'], 'min' => $player['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $player['id'];
|
||||
} elseif (isset($hirarchy[$position][2])) {
|
||||
$position = $hirarchy[$position][2];
|
||||
$player = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
if (isset($player['id'])) {
|
||||
$lineup[$player['id']] = ['id' => $player['id'], 'min' => $player['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $player['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->getPlayerForPosition($lineup, $id_used, $place, $players);
|
||||
}
|
||||
|
||||
$all_lineups[$formation_name] = $lineup;
|
||||
@@ -865,9 +803,14 @@ class PlayerPropsDrop extends Widget
|
||||
$this->generateLineUp();
|
||||
}
|
||||
|
||||
public function getPlayerForPosition()
|
||||
public function getPlayerForPosition(array &$lineup, array &$id_used, int $place, Collection $players)
|
||||
{
|
||||
$position = $this->activeBoxes[$place];
|
||||
|
||||
$hirarchy = PositionHirarchie::load();
|
||||
|
||||
$fitered = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
dd($fitered, $position);
|
||||
if (isset($fitered['id'])) {
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
|
||||
Reference in new issue
Block a user