board memory wip

This commit is contained in:
salam committed 2026-09-12 16:30:04 +02:00
1 parent df1061e51c
commit a6b080248a
3 files changed
+51 -4

No files matched your search

+45 -2
View File
@@ -5,6 +5,7 @@ namespace App\Livewire;
use App\Models\SofaScorePlayerPerSeason;
use App\Models\SofaScorePlayerPosition;
use App\Models\SofaScoreRosa;
use App\Models\SsLineupMemory;
use App\Models\StatisticFixtures;
use App\Models\StatistikoDetail;
use App\Models\User;
@@ -195,7 +196,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
}
}
$this->clearResultTable();
$this->loadPlacement();
}
public function getHeadingTable(): HtmlString
@@ -353,11 +354,51 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
}
}
// dd($this->boxes);
$this->storePlacement();
$this->calculateAspg();
}
public function loadPlacement()
{
$this->clearResultTable();
$res = SsLineupMemory::where('client_id', Auth::user()->client_id)->where('team_id', $this->filters['team_id'])->first();
if ($res) {
$placement = json_decode($res->placement, 1);
foreach ($this->sourceRecords as $k => $record) {
$id = $record['id'];
if (isset($placement[$id])) {
$this->boxes[$placement[$id]] = $record;
$this->sourceRecords[$k]['active'] = 1;
$this->sourceRecords[$k]['pos'] = $record['pos_ori'];
$this->player_on_field_counter++;
}
}
}
}
public function storePlacement()
{
$store = [];
foreach ($this->boxes as $pos => $value) {
if ($value) {
$store[$value['id']] = $pos;
}
}
SsLineupMemory::updateOrCreate([
'client_id' => Auth::user()->client_id,
'team_id' => $this->filters['team_id'],
], [
'placement' => json_encode($store),
'lineup' => $this->lineup_selected,
]);
}
public function updateLineup(?string $state)
{
$this->clearResultTable();
@@ -397,6 +438,8 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$this->sourceRecords[$k]['tsh'] = '';
$this->sourceRecords[$k]['crd'] = '';
}
$this->storePlacement();
}
}