fix update player
This commit is contained in:
1 parent
e3f1e8a8d9
commit
f028a8b2a8
16 files changed
+605
-224
No files matched your search
+21
-23
@@ -3,21 +3,20 @@
|
||||
namespace App\Filament\Pages\Selections;
|
||||
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Filament\Pages\Selections\LoadPositions;
|
||||
use App\Models\SofaScorePlayerCache;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
class LoadPlayer
|
||||
class LoadPlayerSelection
|
||||
{
|
||||
public static function load(int|null $team_id, string|null $team_position, int|null $sofascore_category_id, array|null $season, string|null $seasonmode)
|
||||
public static function load(?int $team_id, ?string $team_position, ?int $sofascore_category_id, ?array $season, ?string $seasonmode)
|
||||
{
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
|
||||
$hash = hash('crc32', $team_id . $team_position . $sofascore_category_id . serialize($season));
|
||||
$hash = hash('crc32', $team_id.$team_position.$sofascore_category_id.serialize($season));
|
||||
$cached_players = SofaScorePlayerCache::where('hash', $hash)->value('players');
|
||||
if ($cached_players) {
|
||||
// return $cached_players;
|
||||
return $cached_players;
|
||||
}
|
||||
|
||||
$matches = StatistikoEvent::whereIn('season', $season)
|
||||
@@ -33,7 +32,6 @@ class LoadPlayer
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
|
||||
$matches_count = count($matches);
|
||||
|
||||
$positions_map = LoadPositions::load();
|
||||
@@ -44,7 +42,7 @@ class LoadPlayer
|
||||
foreach ($player as $val) {
|
||||
if ($val->details) {
|
||||
$player_id = $val->ss_player_id;
|
||||
if (!isset($arr[$player_id])) {
|
||||
if (! isset($arr[$player_id])) {
|
||||
$arr[$player_id]['player_name'] = $val->details->player_name;
|
||||
$arr[$player_id]['events_played_home'] = $val->events_played_home;
|
||||
$arr[$player_id]['events_played_away'] = $val->events_played_away;
|
||||
@@ -80,43 +78,43 @@ class LoadPlayer
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$colorlevel = round($matches_count / 3);
|
||||
|
||||
if (in_array($val['player_position'], $positions_map['MIDFIELD'])) {
|
||||
$position = 'MIDFIELD';
|
||||
} else if (in_array($val['player_position'], $positions_map['DEFENCE'])) {
|
||||
} elseif (in_array($val['player_position'], $positions_map['DEFENCE'])) {
|
||||
$position = 'DEFENCE';
|
||||
} else if (in_array($val['player_position'], $positions_map['ATTACK'])) {
|
||||
} elseif (in_array($val['player_position'], $positions_map['ATTACK'])) {
|
||||
$position = 'ATTACK';
|
||||
} else if (in_array($val['player_position'], $positions_map['GOALKEEPER'])) {
|
||||
} elseif (in_array($val['player_position'], $positions_map['GOALKEEPER'])) {
|
||||
$position = 'GOALKEEPER';
|
||||
} else {
|
||||
$position = 'NO SPECIFIC POSITION';
|
||||
}
|
||||
|
||||
$infostring = $events_played . ' Ev';
|
||||
if ($val['preferred_foot'])
|
||||
$infostring .= ' - ' . $val['preferred_foot'];
|
||||
if ($events_played)
|
||||
$infostring .= ' - ' . round($minues_played / $events_played) . 'min';
|
||||
$infostring = $events_played.' Ev';
|
||||
if ($val['preferred_foot']) {
|
||||
$infostring .= ' - '.$val['preferred_foot'];
|
||||
}
|
||||
if ($events_played) {
|
||||
$infostring .= ' - '.round($minues_played / $events_played).'min';
|
||||
}
|
||||
if ($colorlevel > 1 && $events_played < $colorlevel) {
|
||||
$result[$position][$player_id] = '<span class="text-red-600 dark:text-red-500 cursor-pointer"><b>' . $val['player_name'] . '</b> ' . $position . '<br>' . $infostring . '</span>';
|
||||
} else if ($events_played < $colorlevel * 2) {
|
||||
$result[$position][$player_id] = '<span class="text-blue-600 dark:text-blue-500 cursor-pointer"><b>' . $val['player_name'] . '</b> ' . $position . '<br>' . $infostring . '</span>';
|
||||
$result[$position][$player_id] = '<span class="text-red-600 dark:text-red-500 cursor-pointer"><b>'.$val['player_name'].'</b> '.$position.'<br>'.$infostring.'</span>';
|
||||
} elseif ($events_played < $colorlevel * 2) {
|
||||
$result[$position][$player_id] = '<span class="text-blue-600 dark:text-blue-500 cursor-pointer"><b>'.$val['player_name'].'</b> '.$position.'<br>'.$infostring.'</span>';
|
||||
} else {
|
||||
$result[$position][$player_id] = '<span class="text-green-600 dark:text-green-500 cursor-pointer"><b>' . $val['player_name'] . '</b> ' . $position . '<br>' . $infostring . '</span>';
|
||||
$result[$position][$player_id] = '<span class="text-green-600 dark:text-green-500 cursor-pointer"><b>'.$val['player_name'].'</b> '.$position.'<br>'.$infostring.'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($result)
|
||||
if ($result) {
|
||||
SofaScorePlayerCache::updateOrCreate(['hash' => $hash], ['players' => $result]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function convertToHoursMins(int $time, $format = '%02dh:%02dm')
|
||||
{
|
||||
if ($time < 1) {
|
||||
@@ -5,7 +5,7 @@ namespace App\Filament\Pages;
|
||||
use App\Actions\LoadSofaScoreCategory;
|
||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||
use App\Actions\LoadStatisticFixturesMatchOptions;
|
||||
use App\Filament\Pages\Selections\LoadPlayer;
|
||||
use App\Filament\Pages\Selections\LoadPlayerSelection;
|
||||
use App\Models\SofaScoreCategory;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use App\Models\StatisticFixtures;
|
||||
@@ -347,7 +347,7 @@ class Statistic extends BaseDashboard
|
||||
$season = $get('season');
|
||||
$seasonmode = $get('seasonmode');
|
||||
|
||||
return LoadPlayer::load($team_id, $team_position, $sofascore_category_id, $season, $seasonmode);
|
||||
return LoadPlayerSelection::load($team_id, $team_position, $sofascore_category_id, $season, $seasonmode);
|
||||
}),
|
||||
Select::make('player_on_field')
|
||||
->live()
|
||||
|
||||
Reference in new issue
Block a user