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