add 2 parts for claculation pp wip
This commit is contained in:
1 parent
6d2f4c1052
commit
ad45880506
19 files changed
+1403
-1049
No files matched your search
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
use App\Models\SsLineupMemory;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
trait Placements
|
||||
{
|
||||
public function loadPlacement()
|
||||
{
|
||||
$this->clearResultTable();
|
||||
|
||||
if ($this->team_id) {
|
||||
|
||||
$this->player_on_field_counter = 0;
|
||||
|
||||
$res = SsLineupMemory::where('client_id', Auth::user()->client_id)->where('team_id', $this->team_id)->where('lineup', $this->activeLineUp)->first();
|
||||
|
||||
if ($res) {
|
||||
|
||||
$placement = json_decode($res->placement, 1);
|
||||
|
||||
foreach ($this->players as $k => $record) {
|
||||
|
||||
$id = $record['id'];
|
||||
|
||||
if (isset($placement[$id]) && in_array($placement[$id], $this->lineup)) {
|
||||
$this->boxes[$placement[$id]] = $record;
|
||||
$this->players[$k]['active'] = 1;
|
||||
$this->players[$k]['pos'] = $record['pos_ori'];
|
||||
|
||||
$this->player_on_field_counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// $this->calculateAspg();
|
||||
}
|
||||
|
||||
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->team_id,
|
||||
'lineup' => $this->activeLineUp,
|
||||
], [
|
||||
'placement' => json_encode($store),
|
||||
'team_name' => $this->team_name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user