wip
This commit is contained in:
1 parent
eec5840a6b
commit
f9712cbd25
15 files changed
+247
-22
No files matched your search
@@ -11,14 +11,8 @@ use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
class LoadPlayer
|
||||
{
|
||||
public static function load(Get $get)
|
||||
public static function load(int|null $team_id, string|null $team_position, int|null $sofascore_category_id, array|null $season, string|null $seasonmode)
|
||||
{
|
||||
$team_id = $get('team_id');
|
||||
$team_position = $get('team_position');
|
||||
$sofascore_category_id = $get('sofascore_category_id');
|
||||
$season = $get('season');
|
||||
$seasonmode = $get('seasonmode');
|
||||
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
|
||||
$hash = hash('crc32', $team_id . $team_position . $sofascore_category_id . serialize($season));
|
||||
|
||||
@@ -23,6 +23,8 @@ use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\SlideOverPosition;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Support\RawJs;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\HtmlString;
|
||||
@@ -76,6 +78,29 @@ class Statistic extends BaseDashboard
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('esc')
|
||||
->label('Reset')
|
||||
->icon('phosphor-x-circle')
|
||||
->color('gray')
|
||||
->keyBindings(['esc'])
|
||||
->action('resetFilters'),
|
||||
Action::make('calculator')
|
||||
->modalSubmitAction(false) // Hides the submit button
|
||||
->modalCancelAction(false) // Optional: hides the cancel button too
|
||||
->label('Calculate')
|
||||
->icon('icon-player')
|
||||
->color(fn(): string => $this->filters['team_id'] ? 'primary' : 'gray')
|
||||
->disabled(fn(): string => $this->filters['team_id'] ? false : true)
|
||||
->modalContent(view('filament.modals.player-calculator-modal', ['filters' => $this->filters]))
|
||||
->slideOver()
|
||||
->slideOverPosition(SlideOverPosition::Start)
|
||||
->modalWidth(Width::SevenExtraLarge)
|
||||
];
|
||||
}
|
||||
|
||||
public function filtersForm(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
@@ -314,7 +339,12 @@ class Statistic extends BaseDashboard
|
||||
->tooltip(fn() => $this->tooltip_player_info())
|
||||
)
|
||||
->options(function (Get $get) {
|
||||
return LoadPlayer::load($get);
|
||||
$team_id = $get('team_id');
|
||||
$team_position = $get('team_position');
|
||||
$sofascore_category_id = $get('sofascore_category_id');
|
||||
$season = $get('season');
|
||||
$seasonmode = $get('seasonmode');
|
||||
return LoadPlayer::load($team_id, $team_position, $sofascore_category_id, $season, $seasonmode);
|
||||
}),
|
||||
Select::make('player_on_field')
|
||||
->live()
|
||||
@@ -427,13 +457,6 @@ class Statistic extends BaseDashboard
|
||||
->color('gray')
|
||||
->action(fn(Set $set) => $set('end_date', null))
|
||||
),
|
||||
Action::make('esc')
|
||||
->label('')
|
||||
->tooltip('Reset [esc]')
|
||||
->icon('phosphor-x-circle')
|
||||
->color('gray')
|
||||
->keyBindings(['esc'])
|
||||
->action('resetFilters'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,11 @@ class AlarmBookmaker extends Component implements HasActions, HasSchemas, HasTab
|
||||
'refreshAlarmBookmaker' => '$refresh',
|
||||
];
|
||||
|
||||
public static $default_filter;
|
||||
public static int $default_filter;
|
||||
|
||||
public static function load_filter($sport_id)
|
||||
public static function load_filter(int $sport_id)
|
||||
{
|
||||
self::$default_filter = MultilineSetting::where('sport_id', $sport_id)
|
||||
self::$default_filter = MultilineSetting::where('sport_id', (int) $sport_id)
|
||||
->orderBy('id')->pluck('id')->first();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class AlarmBookmaker extends Component implements HasActions, HasSchemas, HasTab
|
||||
// }),
|
||||
// TextColumn::make('sport.name'),
|
||||
TextColumn::make('alarm_level.name')
|
||||
->color(fn ($record) => $record->alarm_level->color)
|
||||
->color(fn($record) => $record->alarm_level->color)
|
||||
->weight(FontWeight::Black),
|
||||
TextInputColumn::make('alarm_threshold')
|
||||
->tooltip('Between 0.01 - 2.00')
|
||||
@@ -88,13 +88,13 @@ class AlarmBookmaker extends Component implements HasActions, HasSchemas, HasTab
|
||||
->default(self::$default_filter)
|
||||
->columnSpanFull()
|
||||
->hiddenLabel()
|
||||
->options(fn () => MultilineSetting::where('sport_id', auth()->user()->sport_id)->orderBy('name')->pluck('name', 'id')),
|
||||
->options(fn() => MultilineSetting::where('sport_id', auth()->user()->sport_id)->orderBy('name')->pluck('name', 'id')),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['multiline_setting_id'],
|
||||
fn (Builder $query, $multiline_setting_id): Builder => $query->where('multiline_setting_id', $multiline_setting_id),
|
||||
fn(Builder $query, $multiline_setting_id): Builder => $query->where('multiline_setting_id', $multiline_setting_id),
|
||||
);
|
||||
})
|
||||
->columns(6)->columnSpan(6),
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Mapper;
|
||||
|
||||
class LoadPositions
|
||||
{
|
||||
|
||||
public static function load()
|
||||
{
|
||||
$arr = [];
|
||||
|
||||
$arr[] = 0;
|
||||
$arr[] = 0;
|
||||
$arr[] = 'SW';
|
||||
$arr[] = 0;
|
||||
$arr[] = 0;
|
||||
|
||||
$arr[] = 'DR';
|
||||
$arr[] = 'DC';
|
||||
$arr[] = 'DC';
|
||||
$arr[] = 'DC';
|
||||
$arr[] = 'DL';
|
||||
|
||||
$arr[] = 0;
|
||||
$arr[] = 'DM';
|
||||
$arr[] = 'DM';
|
||||
$arr[] = 'DM';
|
||||
$arr[] = 0;
|
||||
|
||||
$arr[] = 'MR';
|
||||
$arr[] = 'MC';
|
||||
$arr[] = 'MC';
|
||||
$arr[] = 'MC';
|
||||
$arr[] = 'ML';
|
||||
|
||||
$arr[] = 0;
|
||||
$arr[] = 'AM';
|
||||
$arr[] = 'AM';
|
||||
$arr[] = 'AM';
|
||||
$arr[] = 0;
|
||||
|
||||
$arr[] = 'RW';
|
||||
$arr[] = 0;
|
||||
$arr[] = 'SM';
|
||||
$arr[] = 0;
|
||||
$arr[] = 'LW';
|
||||
|
||||
$arr[] = 0;
|
||||
$arr[] = 0;
|
||||
$arr[] = 'ST';
|
||||
$arr[] = 0;
|
||||
$arr[] = 0;
|
||||
|
||||
$arr = array_reverse($arr);
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Pages\Selections\LoadPlayer;
|
||||
use App\Livewire\Mapper\LoadPositions;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
use Livewire\Component;
|
||||
|
||||
class PlayerCalculator extends Component
|
||||
{
|
||||
use InteractsWithPageFilters;
|
||||
public $player = [];
|
||||
public $positions = [];
|
||||
|
||||
public function mount(array $filters)
|
||||
{
|
||||
$this->positions = LoadPositions::load();
|
||||
$team_position = $filters['team_position'];
|
||||
$sofascore_category_id = $filters['sofascore_category_id'];
|
||||
$season = $filters['season'];
|
||||
$seasonmode = $filters['seasonmode'];
|
||||
$team_id = $filters['team_id'];
|
||||
$this->player = LoadPlayer::load($team_id, $team_position, $sofascore_category_id, $season, $seasonmode);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user