board memory wip
This commit is contained in:
1 parent
df1061e51c
commit
a6b080248a
3 files changed
+51
-4
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,5 +6,10 @@ use Illuminate\Database\Eloquent\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) {
|
||||
$table->id();
|
||||
$table->integer('client_id')->index();
|
||||
$table->integer('sport_id')->default(1);
|
||||
$table->integer('team_id')->index();
|
||||
$table->string('lineup');
|
||||
$table->text('placement');
|
||||
|
||||
Reference in new issue
Block a user