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,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoDetail;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
trait PlayerAspg
|
||||
{
|
||||
public function calculateAspg(): void
|
||||
{
|
||||
if ($this->player_on_field_counter < 10) {
|
||||
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->dispatch('update-players', players: $this->players);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $this->team_id && ! $this->match_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log::debug('calculateAspg', $this->players);
|
||||
|
||||
// Calcolare Aspettativa Team per GOALS
|
||||
// (il valore che appare quando viene selezionato un Evento): nell' esempio,
|
||||
// se scegliamo come Team il Remo (Home) il valore di riferimento sarà 1.2
|
||||
$team_id = $this->team_id;
|
||||
$match = StatisticFixtures::where('id', $this->match_id)->first();
|
||||
$this->home_id = $match->home_id;
|
||||
$this->away_id = $match->away_id;
|
||||
$this->asp_team = 0;
|
||||
$this->team_home_away = 'home';
|
||||
if ((int) $match->home_id == (int) $team_id) {
|
||||
$this->asp_team = (float) $match->exp_home;
|
||||
$this->team_home_away = 'home';
|
||||
} elseif ((int) $match->away_id == (int) $team_id) {
|
||||
$this->asp_team = (float) $match->exp_away;
|
||||
$this->team_home_away = 'away';
|
||||
}
|
||||
|
||||
$players = StatistikoDetail::where('ss_team_id', $this->team_id)->where('is_active', 1)->get();
|
||||
$this->count_player = 0;
|
||||
foreach ($players as $value) {
|
||||
if ($value['position'] != 'GK') {
|
||||
$this->count_player++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->calculationVariables = [];
|
||||
|
||||
$collection_1 = $this->loadPartsPlayer(1, $players);
|
||||
$collection_2 = $this->loadPartsPlayer(2, $players);
|
||||
|
||||
$filtered_part_1 = $this->filterPlayer($collection_1);
|
||||
$filtered_part_2 = $this->filterPlayer($collection_2);
|
||||
|
||||
$this->mergeData($filtered_part_1, $filtered_part_2);
|
||||
|
||||
$this->dispatch('update-players', players: $this->players);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user