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
@@ -9,6 +9,7 @@ use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class EventMapper extends Page
|
||||
{
|
||||
@@ -36,9 +37,9 @@ class EventMapper extends Page
|
||||
ActionGroup::make([
|
||||
Action::make('bet365')
|
||||
->extraAttributes(['x-on:click' => 'toggle'])
|
||||
->visible(fn (): bool => auth()->user()->provider_id != 2)
|
||||
->visible(fn (): bool => Auth::user()->provider_id != 2)
|
||||
->action(function ($livewire) {
|
||||
User::where('id', auth()->user()->id)->update(['provider_id' => 2]);
|
||||
User::where('id', Auth::user()->id)->update(['provider_id' => 2]);
|
||||
|
||||
Notification::make()
|
||||
->title('Event Mapper changed to Bet365')
|
||||
@@ -49,10 +50,10 @@ class EventMapper extends Page
|
||||
Action::make('magloo_nigeria')
|
||||
->label('MAGLOO NIGERIA')
|
||||
->extraAttributes(['x-on:click' => 'toggle'])
|
||||
->visible(fn (): bool => in_array(auth()->user()->provider_id, [2, 4]))
|
||||
->hidden(fn (): bool => ! in_array(auth()->user()->bookmaker_id, [10, 16]))
|
||||
->visible(fn (): bool => in_array(Auth::user()->provider_id, [2, 4]))
|
||||
->hidden(fn (): bool => ! in_array(Auth::user()->bookmaker_id, [10, 16]))
|
||||
->action(function ($livewire) {
|
||||
User::where('id', auth()->user()->id)->update(['provider_id' => 3]);
|
||||
User::where('id', Auth::user()->id)->update(['provider_id' => 3]);
|
||||
$livewire->dispatch('refresh');
|
||||
|
||||
Notification::make()
|
||||
@@ -63,10 +64,10 @@ class EventMapper extends Page
|
||||
Action::make('magloo_kenia')
|
||||
->label('MAGLOO KENIA')
|
||||
->extraAttributes(['x-on:click' => 'toggle'])
|
||||
->visible(fn (): bool => in_array(auth()->user()->provider_id, [2, 3]))
|
||||
->hidden(fn (): bool => ! in_array(auth()->user()->bookmaker_id, [10, 16]))
|
||||
->visible(fn (): bool => in_array(Auth::user()->provider_id, [2, 3]))
|
||||
->hidden(fn (): bool => ! in_array(Auth::user()->bookmaker_id, [10, 16]))
|
||||
->action(function ($livewire) {
|
||||
User::where('id', auth()->user()->id)->update(['provider_id' => 4]);
|
||||
User::where('id', Auth::user()->id)->update(['provider_id' => 4]);
|
||||
$livewire->dispatch('refresh');
|
||||
|
||||
Notification::make()
|
||||
@@ -77,10 +78,10 @@ class EventMapper extends Page
|
||||
Action::make('logifuture_nigeria')
|
||||
->label('LOGIFUTURE NIGERA')
|
||||
->extraAttributes(['x-on:click' => 'toggle'])
|
||||
->visible(fn (): bool => auth()->user()->provider_id == 6)
|
||||
->hidden(fn (): bool => ! in_array(auth()->user()->bookmaker_id, [35, 36]))
|
||||
->visible(fn (): bool => Auth::user()->provider_id == 6)
|
||||
->hidden(fn (): bool => ! in_array(Auth::user()->bookmaker_id, [35, 36]))
|
||||
->action(function ($livewire) {
|
||||
User::where('id', auth()->user()->id)->update(['provider_id' => 5]);
|
||||
User::where('id', Auth::user()->id)->update(['provider_id' => 5]);
|
||||
|
||||
$livewire->dispatch('refresh');
|
||||
|
||||
@@ -92,10 +93,10 @@ class EventMapper extends Page
|
||||
Action::make('logifuture_colombia')
|
||||
->label('LOGIFUTURE COLOMBIA')
|
||||
->extraAttributes(['x-on:click' => 'toggle'])
|
||||
->visible(fn (): bool => auth()->user()->provider_id == 5)
|
||||
->hidden(fn (): bool => ! in_array(auth()->user()->bookmaker_id, [35, 36]))
|
||||
->visible(fn (): bool => Auth::user()->provider_id == 5)
|
||||
->hidden(fn (): bool => ! in_array(Auth::user()->bookmaker_id, [35, 36]))
|
||||
->action(function ($livewire) {
|
||||
User::where('id', auth()->user()->id)->update(['provider_id' => 6]);
|
||||
User::where('id', Auth::user()->id)->update(['provider_id' => 6]);
|
||||
|
||||
$livewire->dispatch('refresh');
|
||||
|
||||
@@ -107,7 +108,7 @@ class EventMapper extends Page
|
||||
])
|
||||
->label('Swop Bookmaker')
|
||||
->icon('phosphor-dots-three-vertical')
|
||||
->visible(fn (): bool => auth()->user()->hasRole('mapper_source_betsapi'))
|
||||
->visible(fn (): bool => Auth::user()->hasRole('mapper_source_betsapi'))
|
||||
->color('primary')
|
||||
->button(),
|
||||
];
|
||||
|
||||
@@ -15,14 +15,19 @@ use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Navigation\NavigationItem;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\RawJs;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class PlayerProps extends Page implements HasForms
|
||||
@@ -83,21 +88,28 @@ class PlayerProps extends Page implements HasForms
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->columns(5)
|
||||
->components([
|
||||
$this->selectCountry(),
|
||||
$this->selectLeague(),
|
||||
$this->selectMatch(),
|
||||
$this->selectTeam(),
|
||||
$this->selectLineup(),
|
||||
$this->radioSeasonOrDate(),
|
||||
$this->datePickerStartDate(),
|
||||
$this->datePickerEndDate(),
|
||||
Grid::make(9)
|
||||
->schema([
|
||||
$this->selectCountry(),
|
||||
$this->selectLeague(),
|
||||
$this->selectMatch(),
|
||||
$this->selectTeam(),
|
||||
$this->selectLineup(),
|
||||
$this->radioSeasonOrDate(),
|
||||
$this->sliderValue(),
|
||||
$this->selectSeason(),
|
||||
$this->dateSplitter(),
|
||||
View::make('components.form-lockout'),
|
||||
])
|
||||
->extraAttributes([
|
||||
'wire:loading.class' => 'opacity-60 pointer-events-none transition-opacity',
|
||||
]),
|
||||
])->statePath('filterData');
|
||||
}
|
||||
|
||||
#[On('team-update')]
|
||||
public function syncData($team_id)
|
||||
public function syncData(int $team_id)
|
||||
{
|
||||
if ($team_id) {
|
||||
$this->team_id = $team_id;
|
||||
@@ -191,6 +203,7 @@ class PlayerProps extends Page implements HasForms
|
||||
private function selectTeam(): Select
|
||||
{
|
||||
return Select::make('tid')
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->prefixIconColor(fn (Get $get): string => $get('tid') ? 'success' : 'danger')
|
||||
@@ -211,8 +224,11 @@ class PlayerProps extends Page implements HasForms
|
||||
->placeholder('Team')
|
||||
->afterStateUpdated(function ($state, Set $set) {
|
||||
if ($state) {
|
||||
|
||||
$this->dispatch('team-update', team_id: $state);
|
||||
|
||||
$tmp = SsLineupMemory::where('client_id', Auth::user()->client_id)->where('team_id', $state)->orderBy('created_at', 'desc')->first();
|
||||
|
||||
if ($tmp) {
|
||||
$set('lineup', $tmp->lineup);
|
||||
$this->dispatch('lineup-update', activeLineUp: $tmp->lineup);
|
||||
@@ -224,6 +240,7 @@ class PlayerProps extends Page implements HasForms
|
||||
private function selectLeague(): Select
|
||||
{
|
||||
return Select::make('lid')
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->preload()
|
||||
->prefixIconColor(fn (Get $get): string => $get('lid') ? 'success' : 'danger')
|
||||
@@ -231,16 +248,18 @@ class PlayerProps extends Page implements HasForms
|
||||
->hiddenLabel()
|
||||
->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('cid')))
|
||||
->placeholder('League')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
->afterStateUpdated(function (callable $set, $state) {
|
||||
$set('mid', null);
|
||||
$set('tid', null);
|
||||
$this->dispatch('clear-all');
|
||||
$this->dispatch('liga_id-update', liga_id: $state);
|
||||
});
|
||||
}
|
||||
|
||||
private function selectMatch(): Select
|
||||
{
|
||||
return Select::make('mid')
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->prefixIconColor(fn (Get $get): string => $get('mid') ? 'success' : 'danger')
|
||||
@@ -289,6 +308,7 @@ class PlayerProps extends Page implements HasForms
|
||||
private function selectCountry(): Select
|
||||
{
|
||||
return Select::make('cid')
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->preload()
|
||||
->searchable(false)
|
||||
@@ -306,6 +326,9 @@ class PlayerProps extends Page implements HasForms
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* SECOND LINE
|
||||
*/
|
||||
private function radioSeasonOrDate(): Radio
|
||||
{
|
||||
return Radio::make('season_or_date')
|
||||
@@ -318,52 +341,137 @@ class PlayerProps extends Page implements HasForms
|
||||
->default('season')
|
||||
->hiddenLabel()
|
||||
->options([
|
||||
'season' => 'Active Season',
|
||||
'season' => 'Season',
|
||||
'date' => 'Date',
|
||||
])->afterStateUpdated(function ($state) {
|
||||
$this->dispatch('season_or_date-update', season_or_date: $state);
|
||||
});
|
||||
}
|
||||
|
||||
private function datePickerStartDate(): DatePicker
|
||||
private function sliderValue(): Slider
|
||||
{
|
||||
return DatePicker::make('start_date')
|
||||
return Slider::make('part_1_value')
|
||||
->columnSpan(2)
|
||||
->live(debounce: 500)
|
||||
->hiddenLabel()
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') == 'none')
|
||||
->fillTrack()
|
||||
->minValue(0)
|
||||
->maxValue(100)
|
||||
->default(60)
|
||||
->decimalPlaces(0)
|
||||
->tooltips(RawJs::make(<<<'JS'
|
||||
`${$value.toFixed()}%`
|
||||
JS))
|
||||
->pips()
|
||||
->afterStateUpdated(function ($state) {
|
||||
$this->dispatch('part_1_value-update', part_1_value: $state);
|
||||
});
|
||||
}
|
||||
|
||||
private function selectSeason(): Select
|
||||
{
|
||||
return Select::make('season_selected')
|
||||
->live()
|
||||
->columnSpan(2)
|
||||
->hiddenLabel()
|
||||
->multiple()
|
||||
->placeholder('Current Season')
|
||||
->disabled(fn (Get $get) => $get('cid') == null)
|
||||
->hidden(fn (Get $get) => $get('season_or_date') == 'date')
|
||||
->prefixIconColor(fn (Get $get): string => $get('cid') ? 'success' : 'danger')
|
||||
->prefixIcon('phosphor-calendar-star')
|
||||
->suffixAction(
|
||||
Action::make('iconInfo')
|
||||
->icon('phosphor-question')
|
||||
->color('success')
|
||||
->tooltip(function (Get $get) {
|
||||
if ($get('cid') == null) {
|
||||
return 'Select country first';
|
||||
} else {
|
||||
return new HtmlString('Splits data in 2 Parts<br/><span class="text-blue-500">A) Seasons selected, value is % from slider</span><br/><span class="text-green-500">B) Contains rest from DB, value is 100 - slider value</span>');
|
||||
}
|
||||
}))
|
||||
->options(function (Get $get) {
|
||||
if ($get('season_mode') == 'halfyear') {
|
||||
return ['26/27' => '26/27', '25/26' => '25/26', '24/25' => '24/25'];
|
||||
} else {
|
||||
return ['2026' => '2026', '2025' => '2025', '2024' => '2024'];
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, $state) {
|
||||
$set('ss_player_id', null);
|
||||
$this->dispatch('season_selected-update', season_selected: $state);
|
||||
});
|
||||
}
|
||||
|
||||
private function dateSplitter(): DatePicker
|
||||
{
|
||||
return DatePicker::make('date_spliter')
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||
->native(false)
|
||||
->prefixAction(
|
||||
Action::make('iconInfo')
|
||||
->tooltip(fn () => new HtmlString('Splits data in 2 Parts<br/><span class="text-blue-500">A) Data before day selected, takes % from slider</span><br/><span class="text-green-500">B) Data after day selected takes rest, value is % 100 - slider value</span>'))
|
||||
->icon('phosphor-question')
|
||||
->color('success')
|
||||
)
|
||||
->prefixIconColor(fn (Get $get): string => $get('start_date') ? 'success' : 'primary')
|
||||
->prefixIcon('phosphor-calendar')
|
||||
->prefix('Start')
|
||||
// ->prefixIcon('phosphor-calendar')
|
||||
->prefix('Split')
|
||||
->closeOnDateSelection()
|
||||
->suffixAction(
|
||||
Action::make('clear_start')
|
||||
->icon('phosphor-x')
|
||||
->color('gray')
|
||||
->action(fn (Set $set) => $set('start_date', null))
|
||||
->action(fn (Set $set) => $set('date_spliter', null))
|
||||
)->afterStateUpdated(function ($state) {
|
||||
$this->dispatch('start_date-update', start_date: $state);
|
||||
$this->dispatch('date_spliter-update', $state);
|
||||
});
|
||||
}
|
||||
|
||||
private function datePickerEndDate(): DatePicker
|
||||
{
|
||||
return DatePicker::make('end_date')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||
->native(false)
|
||||
->prefixIconColor(fn (Get $get): string => $get('end_date') ? 'success' : 'primary')
|
||||
->prefixIcon('phosphor-calendar')
|
||||
->prefix('End')
|
||||
->closeOnDateSelection()
|
||||
->suffixAction(
|
||||
Action::make('clear_end')
|
||||
->icon('phosphor-x')
|
||||
->color('gray')
|
||||
->action(fn (Set $set) => $set('end_date', null))
|
||||
)->afterStateUpdated(function ($state) {
|
||||
$this->dispatch('end_date-update', end_date: $state);
|
||||
});
|
||||
}
|
||||
// private function datePickerStartDate(): DatePicker
|
||||
// {
|
||||
// return DatePicker::make('start_date')
|
||||
// ->live()
|
||||
// ->hiddenLabel()
|
||||
// ->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||
// ->native(false)
|
||||
// ->prefixIconColor(fn (Get $get): string => $get('start_date') ? 'success' : 'primary')
|
||||
// ->prefixIcon('phosphor-calendar')
|
||||
// ->prefix('Start')
|
||||
// ->closeOnDateSelection()
|
||||
// ->suffixAction(
|
||||
// Action::make('clear_start')
|
||||
// ->icon('phosphor-x')
|
||||
// ->color('gray')
|
||||
// ->action(fn (Set $set) => $set('start_date', null))
|
||||
// )->afterStateUpdated(function ($state) {
|
||||
// $this->dispatch('start_date-update', start_date: $state);
|
||||
// });
|
||||
// }
|
||||
|
||||
// private function datePickerEndDate(): DatePicker
|
||||
// {
|
||||
// return DatePicker::make('end_date')
|
||||
// ->live()
|
||||
// ->hiddenLabel()
|
||||
// ->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||
// ->native(false)
|
||||
// ->prefixIconColor(fn (Get $get): string => $get('end_date') ? 'success' : 'primary')
|
||||
// ->prefixIcon('phosphor-calendar')
|
||||
// ->prefix('End')
|
||||
// ->closeOnDateSelection()
|
||||
// ->suffixAction(
|
||||
// Action::make('clear_end')
|
||||
// ->icon('phosphor-x')
|
||||
// ->color('gray')
|
||||
// ->action(fn (Set $set) => $set('end_date', null))
|
||||
// )->afterStateUpdated(function ($state) {
|
||||
// $this->dispatch('end_date-update', end_date: $state);
|
||||
// });
|
||||
// }
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
trait BestLineUp
|
||||
{
|
||||
public function majorFormations(): array
|
||||
{
|
||||
// 343+
|
||||
// 352
|
||||
// 433+
|
||||
// 442+
|
||||
// 4231
|
||||
// 4321+
|
||||
// 4312+
|
||||
// 4411+
|
||||
return [
|
||||
'343+' => [9, 16, 23, 4, 11, 25, 32, 6, 34, 21],
|
||||
'352' => [9, 16, 23, 4, 11, 17, 25, 32, 20, 21],
|
||||
'433+' => [2, 9, 23, 30, 11, 18, 25, 6, 34, 21],
|
||||
'442+' => [2, 9, 23, 30, 4, 11, 25, 32, 20, 21],
|
||||
'4231' => [2, 9, 23, 30, 10, 24, 12, 19, 26, 21],
|
||||
'4321+' => [2, 9, 23, 30, 11, 18, 25, 12, 26, 21],
|
||||
'4312+' => [2, 9, 23, 30, 11, 18, 25, 19, 20, 21],
|
||||
'4411+' => [2, 9, 23, 30, 4, 11, 25, 32, 19, 21],
|
||||
];
|
||||
}
|
||||
|
||||
public function generateBestLineUp(): void
|
||||
{
|
||||
if (! $this->team_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$all_lineups = [];
|
||||
|
||||
$players = $this->prepareLineUp();
|
||||
|
||||
$major_formations = self::majorFormations();
|
||||
|
||||
foreach ($major_formations as $formation_name => $formation_positions) {
|
||||
|
||||
$lineup = [];
|
||||
|
||||
$id_used = [];
|
||||
|
||||
foreach ($formation_positions as $place) {
|
||||
$this->getPlayerForPosition($lineup, $id_used, $place, $players);
|
||||
}
|
||||
|
||||
$all_lineups[$formation_name] = $lineup;
|
||||
}
|
||||
|
||||
$tmp = [];
|
||||
foreach ($all_lineups as $formation_name => $lineup) {
|
||||
$tmp[$formation_name] = array_sum(array_column($lineup, 'min'));
|
||||
}
|
||||
$formation_name = array_search(max($tmp), $tmp);
|
||||
|
||||
// dd($all_lineups, $tmp, $formation_name);
|
||||
|
||||
$this->dispatch('update-lineup', $formation_name);
|
||||
|
||||
$this->lineUpUpdate($formation_name);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
trait ClearBoxes
|
||||
{
|
||||
public function clearBox(int $boxNumber): void
|
||||
{
|
||||
if (isset($this->boxes[$boxNumber])) {
|
||||
$tmp = $this->boxes[$boxNumber];
|
||||
$player_id = 0;
|
||||
foreach ($tmp as $key => $value) {
|
||||
if ($key == 'id') {
|
||||
$player_id = $value;
|
||||
}
|
||||
}
|
||||
foreach ($this->players as $k => $record) {
|
||||
if ($record['id'] == (int) $player_id) {
|
||||
$this->boxes[$boxNumber] = [];
|
||||
$this->players[$k]['pos'] = '';
|
||||
$this->players[$k]['active'] = 0;
|
||||
|
||||
$this->player_on_field_counter--;
|
||||
}
|
||||
}
|
||||
|
||||
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->storePlacement();
|
||||
|
||||
$this->loadPlacement();
|
||||
}
|
||||
}
|
||||
|
||||
public function clearResultTable(): void
|
||||
{
|
||||
|
||||
for ($i = 1; $i <= 35; $i++) {
|
||||
$this->boxes[$i] = [];
|
||||
}
|
||||
|
||||
foreach ($this->players as $k => $record) {
|
||||
// $this->players[$k] = [];
|
||||
$this->players[$k]['active'] = 0;
|
||||
$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->player_on_field_counter = 0;
|
||||
|
||||
$this->dispatch('update-players', players: $this->players);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
trait CopyData
|
||||
{
|
||||
public function copyDevelopment()
|
||||
{
|
||||
if ($this->player_on_field_counter < 10) {
|
||||
Notification::make()->title('Needs a calculation first ')
|
||||
->info()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$copystring = "Part 1\n";
|
||||
|
||||
foreach ($this->calculationVariables as $k => $part) {
|
||||
foreach ($part as $row) {
|
||||
if ($copystring == '') {
|
||||
$keys = array_keys($row);
|
||||
$copystring .= implode(';', $keys)."\n";
|
||||
}
|
||||
$copystring .= implode(';', $row)."\n";
|
||||
}
|
||||
if ($k == 0) {
|
||||
$copystring .= "\nPart 2\n";
|
||||
}
|
||||
}
|
||||
$this->js("navigator.clipboard.writeText(`$copystring`)");
|
||||
|
||||
Notification::make()
|
||||
->title('Calculation variables copied')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
|
||||
public function copyResult()
|
||||
{
|
||||
if ($this->player_on_field_counter < 10) {
|
||||
Notification::make()->title('Needs a calculation first ')
|
||||
->info()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
$header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'crd', 'snt', 'tsh', 'wfl'];
|
||||
$copystring = implode(';', $header)."\n";
|
||||
foreach ($this->players as $row) {
|
||||
$tmp = [];
|
||||
$tmp[] = $row['name'];
|
||||
$tmp[] = $row['foot'];
|
||||
$tmp[] = $row['tot_evt'];
|
||||
$tmp[] = $row['ave_min'];
|
||||
if ($row['pos']) {
|
||||
$tmp[] = $row['pos'];
|
||||
} else {
|
||||
$tmp[] = $row['pos_ori'];
|
||||
}
|
||||
$tmp[] = $row['active'];
|
||||
$tmp[] = $row['gls'];
|
||||
$tmp[] = $row['fls'];
|
||||
$tmp[] = $row['ofs'];
|
||||
$tmp[] = $row['crd'];
|
||||
$tmp[] = $row['snt'];
|
||||
$tmp[] = $row['tsh'];
|
||||
$tmp[] = $row['wfl'];
|
||||
|
||||
$copystring .= implode(';', $tmp)."\n";
|
||||
}
|
||||
$this->js("navigator.clipboard.writeText(`$copystring`)");
|
||||
|
||||
Notification::make()
|
||||
->title('Results copied')
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
+13
-16
@@ -1,54 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\PlayerProps;
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
class Expectations
|
||||
trait Expectations
|
||||
{
|
||||
public static function load(StatisticFixtures $match)
|
||||
public function loadExpectations()
|
||||
{
|
||||
$home_id = $match->home_id;
|
||||
$away_id = $match->away_id;
|
||||
$data = StatistikoEvent::where(function ($query) use ($home_id, $away_id) {
|
||||
return $query->whereIn('home_id', [$home_id, $away_id])->orWhereIn('away_id', [$home_id, $away_id]);
|
||||
$data = StatistikoEvent::where(function ($query) {
|
||||
return $query->whereIn('home_id', [$this->home_id, $this->away_id])->orWhereIn('away_id', [$this->home_id, $this->away_id]);
|
||||
})->get();
|
||||
|
||||
$work = [];
|
||||
$bettypes = ['gls', 'fls', 'crn', 'ofs', 'crd', 'snt', 'tsh', 'wfl'];
|
||||
foreach ($data as $value) {
|
||||
foreach ($bettypes as $type) {
|
||||
if ($value['home_id'] == $home_id) {
|
||||
if ($value['home_id'] == $this->home_id) {
|
||||
$work[$type]['home_made_total'][] = $value[$type.'_h'];
|
||||
$work[$type]['home_made_home'][] = $value[$type.'_h'];
|
||||
$work[$type]['home_got_total'][] = $value[$type.'_a'];
|
||||
$work[$type]['home_got_home'][] = $value[$type.'_a'];
|
||||
} elseif ($value['away_id'] == $home_id) {
|
||||
} elseif ($value['away_id'] == $this->home_id) {
|
||||
$work[$type]['home_made_total'][] = $value[$type.'_a'];
|
||||
$work[$type]['home_got_total'][] = $value[$type.'_a'];
|
||||
} elseif ($value['home_id'] == $away_id) {
|
||||
} elseif ($value['home_id'] == $this->away_id) {
|
||||
$work[$type]['home_made_total'][] = $value[$type.'_a'];
|
||||
$work[$type]['home_got_total'][] = $value[$type.'_a'];
|
||||
} elseif ($value['away_id'] == $away_id) {
|
||||
} elseif ($value['away_id'] == $this->away_id) {
|
||||
$work[$type]['home_made_total'][] = $value[$type.'_h'];
|
||||
$work[$type]['home_made_home'][] = $value[$type.'_h'];
|
||||
$work[$type]['home_got_total'][] = $value[$type.'_a'];
|
||||
$work[$type]['home_got_home'][] = $value[$type.'_h'];
|
||||
}
|
||||
|
||||
if ($value['away_id'] == $away_id) {
|
||||
if ($value['away_id'] == $this->away_id) {
|
||||
$work[$type]['away_made_total'][] = $value[$type.'_a'];
|
||||
$work[$type]['away_made_away'][] = $value[$type.'_a'];
|
||||
$work[$type]['away_got_total'][] = $value[$type.'_h'];
|
||||
$work[$type]['away_got_away'][] = $value[$type.'_a'];
|
||||
} elseif ($value['away_id'] == $home_id) {
|
||||
} elseif ($value['away_id'] == $this->home_id) {
|
||||
$work[$type]['away_made_total'][] = $value[$type.'_h'];
|
||||
$work[$type]['away_got_total'][] = $value[$type.'_h'];
|
||||
} elseif ($value['home_id'] == $away_id) {
|
||||
} elseif ($value['home_id'] == $this->away_id) {
|
||||
$work[$type]['away_made_total'][] = $value[$type.'_h'];
|
||||
$work[$type]['away_got_total'][] = $value[$type.'_h'];
|
||||
} elseif ($value['away_id'] == $away_id) {
|
||||
} elseif ($value['away_id'] == $this->away_id) {
|
||||
$work[$type]['away_made_total'][] = $value[$type.'_a'];
|
||||
$work[$type]['away_made_away'][] = $value[$type.'_a'];
|
||||
$work[$type]['away_got_total'][] = $value[$type.'_h'];
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\PlayerProps;
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
class LineUpMap
|
||||
trait LineUpMap
|
||||
{
|
||||
public static function load()
|
||||
public static function loadLineUpMaps()
|
||||
{
|
||||
return [
|
||||
'3313' => [9, 16, 23, 11, 18, 25, 19, 6, 34, 21],
|
||||
@@ -59,7 +59,7 @@ class LineUpMap
|
||||
];
|
||||
}
|
||||
|
||||
public static function get(string $key)
|
||||
public static function getLineUpMap(string $key)
|
||||
{
|
||||
$lup = [
|
||||
'3313' => [9, 16, 23, 11, 18, 25, 19, 6, 34, 21],
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
trait LineUps
|
||||
{
|
||||
public function prepareLineUp()
|
||||
{
|
||||
$arr = [
|
||||
'team_id' => $this->team_id,
|
||||
'season_or_date' => $this->season_or_date,
|
||||
'season_mode' => $this->season_mode,
|
||||
];
|
||||
|
||||
$players = $this->loadPlayerAll();
|
||||
|
||||
$arr = collect();
|
||||
foreach ($players as $value) {
|
||||
if ($value['position'] != '') {
|
||||
$arr->push([
|
||||
'id' => $value['ss_player_id'],
|
||||
'min' => $value['average_min'],
|
||||
'pos' => $value['position'],
|
||||
'name' => $value['player_name'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function generateLineUp(): void
|
||||
{
|
||||
if ($this->activeLineUp && $this->team_id) {
|
||||
|
||||
$players = $this->prepareLineUp();
|
||||
|
||||
$places = $this->getLineUpMap($this->activeLineUp);
|
||||
|
||||
$lineup = [];
|
||||
|
||||
$id_used = [];
|
||||
|
||||
foreach ($places as $place) {
|
||||
$this->getPlayerForPosition($lineup, $id_used, $place, $players);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 35; $i++) {
|
||||
$this->boxes[$i] = [];
|
||||
}
|
||||
|
||||
$this->clearResultTable();
|
||||
|
||||
$this->player_on_field_counter = 0;
|
||||
|
||||
foreach ($this->players as $k => $record) {
|
||||
$id = $record['id'];
|
||||
if (isset($lineup[$id])) {
|
||||
|
||||
$this->boxes[$lineup[$id]['place']] = $record;
|
||||
|
||||
$this->players[$k]['active'] = 1;
|
||||
$this->players[$k]['pos'] = $lineup[$id]['position'];
|
||||
|
||||
$this->player_on_field_counter++;
|
||||
} else {
|
||||
$this->players[$k]['active'] = 0;
|
||||
$this->players[$k]['pos'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$this->calculateAspg();
|
||||
|
||||
$this->storePlacement();
|
||||
}
|
||||
}
|
||||
|
||||
public function updateLineup(?string $state)
|
||||
{
|
||||
$this->clearResultTable();
|
||||
|
||||
if (isset($this->lineupsMap[$state])) {
|
||||
$this->lineup = $this->lineUpMap[$state];
|
||||
} else {
|
||||
$this->lineup = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
trait PlayerDataMerge
|
||||
{
|
||||
public function mergeData(array $filtered_part_1, array $filtered_part_2): void
|
||||
{
|
||||
foreach ($this->players as $k => $record) {
|
||||
|
||||
$players_id = $record['id'];
|
||||
|
||||
$part1 = $filtered_part_1[$players_id] ?? [];
|
||||
|
||||
$part2 = $filtered_part_2[$players_id] ?? [];
|
||||
|
||||
$this->players[$k]['active'] = $part1['active'] ?? 0;
|
||||
|
||||
$bets = ['gls', 'crn', 'fls', 'ofs', 'crd', 'snt', 'tsh', 'wfl'];
|
||||
foreach ($bets as $bet) {
|
||||
$this->players[$k][$bet] = $this->calc($bet, $part1, $part2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function calc(string $bettype, array $part1, array $part2)
|
||||
{
|
||||
$val1 = $part1[$bettype] ?? 0;
|
||||
$val2 = $part2[$bettype] ?? 0;
|
||||
|
||||
return number_format(($val2 * (100 - $this->part_1_value) + $val1 * $this->part_1_value) / 100, 3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
use App\Models\ExpectedMinimumPosition;
|
||||
use App\Models\SofaScorePlayerPosition;
|
||||
|
||||
trait PlayerFilter
|
||||
{
|
||||
public function filterPlayer(array $collection)
|
||||
{
|
||||
$results = [];
|
||||
foreach ($collection as $val) {
|
||||
if ($val['position'] != 'GK') {
|
||||
|
||||
/***
|
||||
"goals" => 0
|
||||
"fouls" => 13
|
||||
"cards" => 3
|
||||
"offsides" => 0
|
||||
"shots_on_target" => 3
|
||||
"shots_off_target" => 2
|
||||
"total_shots" => 4
|
||||
*/
|
||||
|
||||
$ss_player_id = $val['ss_player_id'];
|
||||
$position = $val['position'];
|
||||
|
||||
$tmp = [];
|
||||
$tmp['id'] = $ss_player_id;
|
||||
$tmp['name'] = $val['player_name'];
|
||||
|
||||
$tmp['id_team'] = $this->team_id;
|
||||
$tmp['asp_team'] = $this->asp_team;
|
||||
$tmp['player_count_without_gk'] = $this->count_player;
|
||||
|
||||
$position_field = $this->get_position($ss_player_id);
|
||||
if ($position_field) {
|
||||
$position = $position_field;
|
||||
$tmp['active'] = 1;
|
||||
} else {
|
||||
$tmp['active'] = 0;
|
||||
}
|
||||
$tmp['pos'] = $position;
|
||||
|
||||
// Aspettativa di Gioco (AdG) = Somma Goals fatti da Player nel DB / Somma Minuti Giocati da Player (SMG) nel DB * 90.
|
||||
// Se la SMG è < Y per quel Player prenderemo in considerazione solo l'Aspettativa Statistica (AS).
|
||||
// Il valore Y dovrebbe essere configurabile in una interfaccia. Il valore iniziale lo fissiamo a Y = 180
|
||||
|
||||
// Somma Minuti Giocati da Player (SMG) nel DB
|
||||
$tmp['somma_minuti'] = $val['total_min'];
|
||||
$tmp['shots_on_target'] = $val['shots_on_target'];
|
||||
$tmp['shots_off_target'] = $val['shots_off_target'];
|
||||
$tmp['shots_blocked'] = $val['shots_blocked'];
|
||||
|
||||
// il valore corrispondente al ruolo del Player (esempio un giocatore in Details ha ruolo = RW
|
||||
// quindi Aspettativa Statistica (AS) per RW = 0.219)
|
||||
// exp_goals
|
||||
// exp_assists
|
||||
// exp_cards
|
||||
// exp_fouls
|
||||
// exp_was_fouled
|
||||
// exp_offsides
|
||||
// exp_total_shots
|
||||
// exp_shots_on_target
|
||||
|
||||
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target', 'was_fouled'];
|
||||
foreach ($bettypes as $bettype) {
|
||||
|
||||
$asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_'.$bettype);
|
||||
$tmp['asp_statistica_'.$bettype] = $asp_statistica;
|
||||
|
||||
// if ($val->ss_player_id == 243651)
|
||||
// dd($val, $asp_statistica);
|
||||
|
||||
// if ($val->total_min < $this->y_value) {
|
||||
// $asp_gioco = 0;
|
||||
// } else {
|
||||
// $asp_gioco = $val->shots_on_target / $val->total_min * 90;
|
||||
// }
|
||||
|
||||
switch ($bettype) {
|
||||
case 'goals':
|
||||
$asp_gioco = $val['goals'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
|
||||
}
|
||||
break;
|
||||
case 'cards':
|
||||
$asp_gioco = $val['cards'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
|
||||
}
|
||||
break;
|
||||
case 'fouls':
|
||||
$asp_gioco = $val['fouls'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
|
||||
}
|
||||
break;
|
||||
case 'offsides':
|
||||
$asp_gioco = $val['offsides'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
|
||||
}
|
||||
break;
|
||||
case 'total_shots':
|
||||
$asp_gioco = $val['total_shots'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
|
||||
}
|
||||
break;
|
||||
case 'shots_on_target':
|
||||
$asp_gioco = $val['shots_on_target'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
|
||||
}
|
||||
break;
|
||||
case 'was_fouled':
|
||||
$asp_gioco = $val['was_fouled'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
$tmp['asp_gioco_'.$bettype] = $asp_gioco;
|
||||
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Calcolare la Somma di tutte le AT (colonna G della Tabella)
|
||||
// Considerare la ATR calcolata allo Step 1 (colonna I della Tabella)
|
||||
// Aspettativa per Player: AP = AT * ATR / TOT AT
|
||||
$results[] = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
$asp_team_all = $this->loadExpectations();
|
||||
|
||||
// Aspettativa Team di Riferimento
|
||||
// (ATR) = Aspettativa Team * Numero di Giocatori di Team in Rosters (esclusi i portieri) / 10.
|
||||
// Ad esempio per Remo (supponiamo 24 giocatori nel Roster esclusi i portieri): ATR = 1.2 * 24 / 10 = 2.88
|
||||
|
||||
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target', 'was_fouled'];
|
||||
foreach ($bettypes as $bettype) {
|
||||
|
||||
$total_bettype = array_sum(array_column($results, 'asp_teorica_'.$bettype));
|
||||
|
||||
foreach ($results as $key => $value) {
|
||||
switch ($bettype) {
|
||||
case 'goals':
|
||||
// Aspettativa per Player: AP = AT * ATR / TOT AT
|
||||
// $results[$key]['asp_player_'.$bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_'.$bettype]) / $total_bettype;
|
||||
// $results[$key]['asp_player_'.$bettype] = ($asp_team * $asp_team_riferimento) / $total_bettype;
|
||||
|
||||
$asp_team_riferimento = (float) $this->asp_team * $this->count_player / 10;
|
||||
$results[$key]['asp_riferimento_goals'] = $asp_team_riferimento;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
break;
|
||||
case 'cards':
|
||||
$asp_team_riferimento = (float) $asp_team_all[$this->team_home_away]['crd'] * $this->count_player / 10;
|
||||
$results[$key]['asp_team_riferimento_card'] = $asp_team_riferimento;
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||
break;
|
||||
case 'fouls':
|
||||
$asp_team_riferimento = (float) $asp_team_all[$this->team_home_away]['fls'] * $this->count_player / 10;
|
||||
$results[$key]['asp_team_riferimento_fouls'] = $asp_team_riferimento;
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||
break;
|
||||
case 'offsides':
|
||||
$asp_team_riferimento = (float) $asp_team_all[$this->team_home_away]['ofs'] * $this->count_player / 10;
|
||||
$results[$key]['asp_team_riferimento_offside'] = $asp_team_riferimento;
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||
break;
|
||||
case 'total_shots':
|
||||
$asp_team_riferimento = (float) $asp_team_all[$this->team_home_away]['tsh'] * $this->count_player / 10;
|
||||
$results[$key]['asp_team_riferimento_tsh'] = $asp_team_riferimento;
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||
break;
|
||||
case 'shots_on_target':
|
||||
$asp_team_riferimento = (float) $asp_team_all[$this->team_home_away]['snt'] * $this->count_player / 10;
|
||||
$results[$key]['asp_team_riferimento_snt'] = $asp_team_riferimento;
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||
break;
|
||||
case 'was_fouled':
|
||||
$asp_team_riferimento = (float) $asp_team_all[$this->team_home_away]['wfl'] * $this->count_player / 10;
|
||||
$results[$key]['asp_team_riferimento_wfl'] = $asp_team_riferimento;
|
||||
$results[$key]['asp_total_'.$bettype] = $total_bettype;
|
||||
$results[$key]['asp_player_'.$bettype] = $value['asp_teorica_'.$bettype] * $asp_team_riferimento / $total_bettype;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$map = [];
|
||||
$res = ExpectedMinimumPosition::all();
|
||||
foreach ($res as $val) {
|
||||
$map[$val->position]['gls'] = $val->gls;
|
||||
$map[$val->position]['crd'] = $val->crd;
|
||||
$map[$val->position]['fls'] = $val->fls;
|
||||
$map[$val->position]['ofs'] = $val->ofs;
|
||||
$map[$val->position]['tsh'] = $val->tsh;
|
||||
$map[$val->position]['snt'] = $val->snt;
|
||||
$map[$val->position]['wfl'] = $val->wfl;
|
||||
}
|
||||
|
||||
// stesso ordine di prima: GLS, CRD, FLS, OFS, TSH, SNT, WFL
|
||||
|
||||
$return = [];
|
||||
foreach ($this->players as $k => $player) {
|
||||
foreach ($results as $key => $result) {
|
||||
if ((int) $player['id'] == (int) $result['id']) {
|
||||
|
||||
$id = $result['id'];
|
||||
$return[$id]['active'] = $result['active'];
|
||||
$pos = $this->players[$k]['pos'];
|
||||
if (! $pos) {
|
||||
$pos = $this->players[$k]['pos_ori'];
|
||||
}
|
||||
|
||||
if ($pos != 'GK') {
|
||||
$tamx = number_format($map[$pos]['gls'], 3);
|
||||
$final = number_format($result['asp_player_goals'], 3);
|
||||
$results[$key]['finale_tamx_gls'] = $tamx;
|
||||
$results[$key]['finale_calc_gls'] = $final;
|
||||
$return[$id]['gls'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['crd'], 3);
|
||||
$final = number_format($result['asp_player_cards'], 3);
|
||||
$results[$key]['finale_tamx_crd'] = $tamx;
|
||||
$results[$key]['finale_calc_crd'] = $final;
|
||||
$return[$id]['crd'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['fls'], 3);
|
||||
$final = number_format($result['asp_player_fouls'], 3);
|
||||
$results[$key]['finale_tamx_fls'] = $tamx;
|
||||
$results[$key]['finale_calc_fls'] = $final;
|
||||
$return[$id]['fls'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['ofs'], 3);
|
||||
$final = number_format($result['asp_player_offsides'], 3);
|
||||
$results[$key]['finale_tamx_ofs'] = $tamx;
|
||||
$results[$key]['finale_calc_ofs'] = $final;
|
||||
$return[$id]['ofs'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['tsh'], 3);
|
||||
$final = number_format($result['asp_player_total_shots'], 3);
|
||||
$results[$key]['finale_tamx_tsh'] = $tamx;
|
||||
$results[$key]['finale_calc_tsh'] = $final;
|
||||
$return[$id]['tsh'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['snt'], 3);
|
||||
$final = number_format($result['asp_player_shots_on_target'], 3);
|
||||
$results[$key]['finale_tamx_snt'] = $tamx;
|
||||
$results[$key]['finale_calc_snt'] = $final;
|
||||
$return[$id]['snt'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['wfl'], 3);
|
||||
$final = number_format($result['asp_player_was_fouled'], 3);
|
||||
$results[$key]['finale_tamx_wfl'] = $tamx;
|
||||
$results[$key]['finale_calc_wfl'] = $final;
|
||||
$return[$id]['wfl'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->calculationVariables[] = $results;
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
use App\Filament\Widgets\PlayerProps\PositionHirarchie;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
trait PlayerForPosition
|
||||
{
|
||||
public function getPlayerForPosition(array &$lineup, array &$id_used, int $place, Collection $players)
|
||||
{
|
||||
$log = 0;
|
||||
|
||||
$position = $this->activeBoxes[$place];
|
||||
|
||||
$hirarchy = PositionHirarchie::load();
|
||||
|
||||
$fitered = $players->where('pos', $position)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
|
||||
if ($log) {
|
||||
Log::debug("A $place - $position", $fitered);
|
||||
}
|
||||
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
} else {
|
||||
if (isset($hirarchy[$position])) {
|
||||
$position2 = $hirarchy[$position][0];
|
||||
$fitered = $players->where('pos', $position2)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
if ($log) {
|
||||
Log::debug("B $place - $position $position2", $fitered);
|
||||
}
|
||||
|
||||
} elseif (isset($hirarchy[$position][1])) {
|
||||
$position3 = $hirarchy[$position][1];
|
||||
$fitered = $players->where('pos', $position3)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
if ($log) {
|
||||
Log::debug("C $place - $position $position2 $position3", $fitered);
|
||||
}
|
||||
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
} elseif (isset($hirarchy[$position][2])) {
|
||||
$position4 = $hirarchy[$position][2];
|
||||
$fitered = $players->where('pos', $position4)->whereNotIn('id', $id_used)->sortByDesc('min')->first();
|
||||
|
||||
if (isset($fitered['id'])) {
|
||||
if ($log) {
|
||||
Log::debug("D $place - $position $position2 $position3 $position4", $fitered);
|
||||
}
|
||||
|
||||
$lineup[$fitered['id']] = ['id' => $fitered['id'], 'min' => $fitered['min'], 'place' => $place, 'position' => $position];
|
||||
$id_used[] = $fitered['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
trait PlayerQuery
|
||||
{
|
||||
public function loadPartsPlayer(int $part, object $players): array
|
||||
{
|
||||
$player_ids = [];
|
||||
foreach ($players as $row) {
|
||||
$player_ids[] = $row->ss_player_id;
|
||||
}
|
||||
|
||||
$matches_ids = [];
|
||||
switch ($this->season_or_date) {
|
||||
case 'season':
|
||||
if (! $this->season_selected) {
|
||||
$this->season_selected = $this->getCurrentSeason();
|
||||
// dd($this->liga_id, $this->season_selected);
|
||||
}
|
||||
$matches_ids = match ($part) {
|
||||
1 => StatistikoEvent::where('league_id', $this->liga_id)
|
||||
->when($this->season_selected, function ($query) {
|
||||
return $query->whereIn('season', $this->season_selected);
|
||||
})->pluck('match_id')->toArray(),
|
||||
2 => StatistikoEvent::where('league_id', $this->liga_id)
|
||||
->when($this->season_selected, function ($query) {
|
||||
return $query->whereNotIn('season', $this->season_selected);
|
||||
})->pluck('match_id')->toArray()
|
||||
};
|
||||
break;
|
||||
default:
|
||||
$matches_ids = match ($part) {
|
||||
1 => StatistikoEvent::where('league_id', $this->liga_id)
|
||||
->when($this->date_spliter, function ($query) {
|
||||
return $query->whereDate('starttime', '>', $this->date_spliter);
|
||||
})->pluck('match_id')->toArray(),
|
||||
2 => StatistikoEvent::where('league_id', $this->liga_id)
|
||||
->when($this->season_selected, function ($query) {
|
||||
return $query->whereDate('starttime', '<=', $this->date_spliter);
|
||||
})->pluck('match_id')->toArray()
|
||||
};
|
||||
}
|
||||
|
||||
$res = StatistikoPlayer::with('details')->whereIn('ss_player_id', $player_ids)->whereIn('match_id', $matches_ids)->get();
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
|
||||
$ss_player_id = (int) $val->ss_player_id;
|
||||
$activeteam_id = (int) $val->activeteam_id;
|
||||
$minutes_played = (int) $val->minutes_played;
|
||||
$home_id = (int) $val->event->home_id;
|
||||
$away_id = (int) $val->event->away_id;
|
||||
|
||||
if (! isset($arr[$ss_player_id])) {
|
||||
self::array_template($arr, $ss_player_id);
|
||||
}
|
||||
|
||||
if ($activeteam_id == $home_id) {
|
||||
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||
} elseif ($activeteam_id == $away_id) {
|
||||
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||
}
|
||||
$cards = $val->card_yellow + $val->card_yellowred;
|
||||
|
||||
$arr[$ss_player_id]['ss_player_id'] = $ss_player_id;
|
||||
$arr[$ss_player_id]['total_events']++;
|
||||
$arr[$ss_player_id]['total_min'] += $minutes_played;
|
||||
$arr[$ss_player_id]['average_min'] = round($arr[$ss_player_id]['total_min'] / $arr[$ss_player_id]['total_events']);
|
||||
$arr[$ss_player_id]['goals'] += $val->goals;
|
||||
$arr[$ss_player_id]['fouls'] += $val->fouls;
|
||||
$arr[$ss_player_id]['cards'] += $cards;
|
||||
$arr[$ss_player_id]['offsides'] += $val->offsides;
|
||||
$arr[$ss_player_id]['shots_on_target'] += $val->shots_on_target;
|
||||
$arr[$ss_player_id]['shots_off_target'] += $val->shots_off_target;
|
||||
$arr[$ss_player_id]['shots_blocked'] += $val->shots_blocked;
|
||||
$arr[$ss_player_id]['total_shots'] += $val->shots_on_target + $val->shots_off_target + $val->shots_blocked;
|
||||
$arr[$ss_player_id]['was_fouled'] += $val->was_fouled;
|
||||
}
|
||||
|
||||
foreach ($players as $player) {
|
||||
if (isset($arr[$player->ss_player_id])) {
|
||||
$arr[$player->ss_player_id]['position'] = $player->position;
|
||||
$arr[$player->ss_player_id]['player_name'] = $player->player_name;
|
||||
$arr[$player->ss_player_id]['preferred_foot'] = $player->preferred_foot;
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function loadPlayerAll(): array
|
||||
{
|
||||
if (! $this->team_id) {
|
||||
return [];
|
||||
}
|
||||
if (! $this->liga_id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$players = StatistikoDetail::where('ss_team_id', $this->team_id)->where('is_active', 1)->get();
|
||||
|
||||
$player_ids = [];
|
||||
foreach ($players as $player) {
|
||||
$player_ids[] = $player->ss_player_id;
|
||||
}
|
||||
|
||||
$matches_ids = StatistikoEvent::where('league_id', $this->liga_id)->pluck('match_id')->toArray();
|
||||
$res = StatistikoPlayer::with('details')->whereIn('ss_player_id', $player_ids)->whereIn('match_id', $matches_ids)->get();
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
|
||||
$ss_player_id = (int) $val->ss_player_id;
|
||||
$activeteam_id = (int) $val->activeteam_id;
|
||||
$minutes_played = (int) $val->minutes_played;
|
||||
$home_id = (int) $val->event->home_id;
|
||||
$away_id = (int) $val->event->away_id;
|
||||
|
||||
if (! isset($arr[$ss_player_id])) {
|
||||
self::array_template($arr, $ss_player_id);
|
||||
}
|
||||
|
||||
if ($activeteam_id == $home_id) {
|
||||
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||
} elseif ($activeteam_id == $away_id) {
|
||||
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||
}
|
||||
$cards = $val->card_yellow + $val->card_yellowred;
|
||||
|
||||
$arr[$ss_player_id]['ss_player_id'] = $ss_player_id;
|
||||
$arr[$ss_player_id]['total_events']++;
|
||||
$arr[$ss_player_id]['total_min'] += $minutes_played;
|
||||
$arr[$ss_player_id]['average_min'] = round($arr[$ss_player_id]['total_min'] / $arr[$ss_player_id]['total_events']);
|
||||
$arr[$ss_player_id]['goals'] += $val->goals;
|
||||
$arr[$ss_player_id]['fouls'] += $val->fouls;
|
||||
$arr[$ss_player_id]['cards'] += $cards;
|
||||
$arr[$ss_player_id]['offsides'] += $val->offsides;
|
||||
$arr[$ss_player_id]['shots_on_target'] += $val->shots_on_target;
|
||||
$arr[$ss_player_id]['shots_off_target'] += $val->shots_off_target;
|
||||
$arr[$ss_player_id]['shots_blocked'] += $val->shots_blocked;
|
||||
$arr[$ss_player_id]['total_shots'] += $val->shots_on_target + $val->shots_off_target + $val->shots_blocked;
|
||||
$arr[$ss_player_id]['was_fouled'] += $val->was_fouled;
|
||||
}
|
||||
|
||||
foreach ($players as $value) {
|
||||
if (isset($arr[$value->ss_player_id])) {
|
||||
$arr[$value->ss_player_id]['position'] = $value->position;
|
||||
$arr[$value->ss_player_id]['player_name'] = $value->player_name;
|
||||
$arr[$value->ss_player_id]['preferred_foot'] = $value->preferred_foot;
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public static function array_template(array &$arr, int $ss_player_id)
|
||||
{
|
||||
$arr[$ss_player_id]['ss_player_id'] = 0;
|
||||
$arr[$ss_player_id]['total_events'] = 0;
|
||||
$arr[$ss_player_id]['total_min'] = 0;
|
||||
$arr[$ss_player_id]['average_min'] = 0;
|
||||
$arr[$ss_player_id]['events_played_home'] = 0;
|
||||
$arr[$ss_player_id]['events_played_away'] = 0;
|
||||
$arr[$ss_player_id]['minutes_played_home'] = 0;
|
||||
$arr[$ss_player_id]['minutes_played_away'] = 0;
|
||||
$arr[$ss_player_id]['goals'] = 0;
|
||||
$arr[$ss_player_id]['fouls'] = 0;
|
||||
$arr[$ss_player_id]['offsides'] = 0;
|
||||
$arr[$ss_player_id]['shots_on_target'] = 0;
|
||||
$arr[$ss_player_id]['shots_off_target'] = 0;
|
||||
$arr[$ss_player_id]['shots_blocked'] = 0;
|
||||
$arr[$ss_player_id]['total_shots'] = 0;
|
||||
$arr[$ss_player_id]['was_fouled'] = 0;
|
||||
$arr[$ss_player_id]['cards'] = 0;
|
||||
}
|
||||
|
||||
public function getCurrentSeason()
|
||||
{
|
||||
|
||||
$tmp = [];
|
||||
$date = Carbon::now();
|
||||
if ($this->season_mode == 'halfyear') {
|
||||
if ((int) date('m') > 7) {
|
||||
$tmp[] = $date->format('y').'/'.$date->format('y') + 1;
|
||||
} else {
|
||||
$tmp[] = $date->format('y') - 1 .'/'.$date->format('y');
|
||||
}
|
||||
} else {
|
||||
$tmp[] = (string) $date->year;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits\PlayerProps;
|
||||
|
||||
use App\Filament\Pages\Selections\LoadPositions;
|
||||
use App\Models\SofaScoreRosa;
|
||||
|
||||
trait SyncData
|
||||
{
|
||||
public function syncData(int $team_id)
|
||||
{
|
||||
if ($team_id) {
|
||||
$this->players = [];
|
||||
|
||||
$positions_map = LoadPositions::load();
|
||||
|
||||
$players = $this->loadPlayerAll();
|
||||
|
||||
foreach ($players as $val) {
|
||||
|
||||
$tmp = [];
|
||||
$tmp['id'] = $val['ss_player_id'];
|
||||
$tmp['name'] = $val['player_name'];
|
||||
$tmp['pos_ori'] = $val['position'];
|
||||
$tmp['foot'] = $val['preferred_foot'];
|
||||
$tmp['pos'] = '';
|
||||
$tmp['active'] = 0;
|
||||
$tmp['tot_evt'] = $val['total_events'];
|
||||
$tmp['tot_min'] = $val['total_min'];
|
||||
$tmp['ave_min'] = $val['average_min'];
|
||||
$tmp['gls'] = $val['goals'];
|
||||
$tmp['fls'] = $val['fouls'];
|
||||
$tmp['ofs'] = $val['offsides'];
|
||||
$tmp['crd'] = $val['cards'];
|
||||
$tmp['snt'] = $val['shots_on_target'];
|
||||
$tmp['tsh'] = $val['shots_off_target'];
|
||||
$tmp['wfl'] = $val['was_fouled'];
|
||||
|
||||
$level = round($val['total_events'] / 3);
|
||||
if ($val['total_events']) {
|
||||
if ($level > 1 && $val['total_events'] < $level) {
|
||||
$tmp['color_evt'] = 'danger';
|
||||
} elseif ($val['total_events'] < $level * 2) {
|
||||
$tmp['color_evt'] = 'info';
|
||||
} else {
|
||||
$tmp['color_evt'] = 'success';
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($val['position'], $positions_map['MIDFIELD'])) {
|
||||
$tmp['area'] = 'midfield';
|
||||
$tmp['color_pos'] = 'info';
|
||||
$tmp['order'] = 2;
|
||||
} elseif (in_array($val['position'], $positions_map['DEFENCE'])) {
|
||||
$tmp['area'] = 'defence';
|
||||
$tmp['color_pos'] = 'success';
|
||||
$tmp['order'] = 1;
|
||||
} elseif (in_array($val['position'], $positions_map['ATTACK'])) {
|
||||
$tmp['area'] = 'attack';
|
||||
$tmp['color_pos'] = 'warning';
|
||||
$tmp['order'] = 3;
|
||||
} elseif (in_array($val['position'], $positions_map['GOALKEEPER'])) {
|
||||
$tmp['area'] = 'goalkeeper';
|
||||
$tmp['color_pos'] = 'gray';
|
||||
$tmp['order'] = 4;
|
||||
} else {
|
||||
$tmp['area'] = 'defence';
|
||||
$tmp['color_pos'] = 'success';
|
||||
$tmp['order'] = 5;
|
||||
}
|
||||
|
||||
$this->players[] = $tmp;
|
||||
}
|
||||
|
||||
$this->team_name = SofaScoreRosa::where('ss_team_id', $this->team_id)->value('ss_team_name');
|
||||
|
||||
$this->loadPlacement();
|
||||
} else {
|
||||
$this->team_name = '';
|
||||
$this->clearResultTable();
|
||||
$this->players = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,9 @@ trait GrappingTeams
|
||||
}
|
||||
|
||||
switch ($title = $this->select_what_to_grap()) {
|
||||
case 'all':
|
||||
$tournaments = SofaScoreTournament::where('enabled', 1)->pluck('tournament_id')->toArray();
|
||||
break;
|
||||
case 'major':
|
||||
$tournaments = SofaScoreTournament::where('enabled', 1)->whereIn('tournament_id', $major)->pluck('tournament_id')->toArray();
|
||||
break;
|
||||
@@ -106,7 +109,9 @@ trait GrappingTeams
|
||||
{
|
||||
return select(
|
||||
label: 'What teams should be grapped?',
|
||||
default: 'all',
|
||||
options: [
|
||||
'all' => 'All Leagues',
|
||||
'major' => 'Major Leagues',
|
||||
'others' => 'Others Leagues',
|
||||
'manual' => 'Enter team_ids (sofa_score_rosas)',
|
||||
|
||||
+1
-3
@@ -10,9 +10,7 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
//
|
||||
})
|
||||
->withMiddleware(function (Middleware $middleware): void {})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
})->create();
|
||||
@@ -0,0 +1,18 @@
|
||||
<div x-data="{ isBlocked: false }"
|
||||
x-init="
|
||||
document.addEventListener('livewire:initialized', () => {
|
||||
Livewire.hook('request', ({ respond }) => {
|
||||
isBlocked = true;
|
||||
respond(() => {
|
||||
isBlocked = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
"
|
||||
x-show="isBlocked"
|
||||
style="display: none;">
|
||||
<svg class="my-1.5 mx-3 animate-spin h-7 w-7 text-danger-600" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
Reference in new issue
Block a user