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\SofaScorePlayerPerSeason;
use App\Models\SofaScorePlayerPosition; use App\Models\SofaScorePlayerPosition;
use App\Models\SofaScoreRosa; use App\Models\SofaScoreRosa;
use App\Models\SsLineupMemory;
use App\Models\StatisticFixtures; use App\Models\StatisticFixtures;
use App\Models\StatistikoDetail; use App\Models\StatistikoDetail;
use App\Models\User; use App\Models\User;
@@ -195,7 +196,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
} }
} }
$this->clearResultTable(); $this->loadPlacement();
} }
public function getHeadingTable(): HtmlString public function getHeadingTable(): HtmlString
@@ -353,11 +354,51 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
} }
} }
// dd($this->boxes); $this->storePlacement();
$this->calculateAspg(); $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) public function updateLineup(?string $state)
{ {
$this->clearResultTable(); $this->clearResultTable();
@@ -397,6 +438,8 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
$this->sourceRecords[$k]['tsh'] = ''; $this->sourceRecords[$k]['tsh'] = '';
$this->sourceRecords[$k]['crd'] = ''; $this->sourceRecords[$k]['crd'] = '';
} }
$this->storePlacement();
} }
} }
+6 -1
View File
@@ -6,5 +6,10 @@ use Illuminate\Database\Eloquent\Model;
class SsLineupMemory extends Model class SsLineupMemory extends Model
{ {
// protected $fillable = [
'client_id',
'team_id',
'lineup',
'placement',
];
} }
@@ -14,7 +14,6 @@ return new class extends Migration
Schema::create('ss_lineup_memories', function (Blueprint $table) { Schema::create('ss_lineup_memories', function (Blueprint $table) {
$table->id(); $table->id();
$table->integer('client_id')->index(); $table->integer('client_id')->index();
$table->integer('sport_id')->default(1);
$table->integer('team_id')->index(); $table->integer('team_id')->index();
$table->string('lineup'); $table->string('lineup');
$table->text('placement'); $table->text('placement');