Files
nuhodds_fi4/app/Traits/PlayerProps/ClearBoxes.php
T

67 lines
1.9 KiB
PHP

<?php
namespace App\Traits\PlayerProps;
trait ClearBoxes
{
public function clearBox(int $boxNumber): void
{
if (isset($this->boxes[$boxNumber])) {
$tmp = $this->boxes[$boxNumber];
$player_id = 0;
foreach ($tmp as $key => $value) {
if ($key == 'id') {
$player_id = $value;
}
}
foreach ($this->players as $k => $record) {
if ($record['id'] == (int) $player_id) {
$this->boxes[$boxNumber] = [];
$this->players[$k]['pos'] = '';
$this->players[$k]['active'] = 0;
$this->player_on_field_counter--;
}
}
foreach ($this->players as $k => $record) {
$this->players[$k]['gls'] = '';
$this->players[$k]['fls'] = '';
$this->players[$k]['ofs'] = '';
$this->players[$k]['crd'] = '';
$this->players[$k]['snt'] = '';
$this->players[$k]['tsh'] = '';
$this->players[$k]['wfl'] = '';
}
$this->storePlacement();
$this->loadPlacement();
}
}
public function clearResultTable(): void
{
for ($i = 1; $i <= 35; $i++) {
$this->boxes[$i] = [];
}
foreach ($this->players as $k => $record) {
// $this->players[$k] = [];
$this->players[$k]['active'] = 0;
$this->players[$k]['gls'] = '';
$this->players[$k]['fls'] = '';
$this->players[$k]['ofs'] = '';
$this->players[$k]['crd'] = '';
$this->players[$k]['snt'] = '';
$this->players[$k]['tsh'] = '';
$this->players[$k]['wfl'] = '';
}
$this->player_on_field_counter = 0;
$this->dispatch('update-players', players: $this->players);
}
}