wip
This commit is contained in:
1 parent
550ea115f1
commit
c036814366
12 files changed
+481
-18891
No files matched your search
@@ -4,7 +4,9 @@ namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\UbEvents\UbEventResource;
|
||||
use App\Filament\Imports\UbEventImporter;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ImportAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUbEvents extends ListRecords
|
||||
@@ -16,9 +18,26 @@ class ListUbEvents extends ListRecords
|
||||
return [
|
||||
ImportAction::make('importPlayer')
|
||||
->icon('phosphor-upload')
|
||||
->label('Events')
|
||||
->modalDescription('Separator comma ";"')
|
||||
->importer(UbEventImporter::class),
|
||||
->label('Import')
|
||||
->modalIcon('phosphor-file-csv')
|
||||
->modalDescription('Separator ";"')
|
||||
->modalHeading('Import events with player')
|
||||
->importer(UbEventImporter::class)
|
||||
->csvDelimiter(';')
|
||||
->extraModalFooterActions([
|
||||
Action::make('copy')
|
||||
->tooltip('Copy header line')
|
||||
->color('success')
|
||||
->label('Copy csv header')
|
||||
->action(function ($livewire) {
|
||||
$livewire->js('window.navigator.clipboard.writeText("league_id;home_id;away_id;starttime;player_id;home_away;home_ft;away_ft;home_ht;away_ht;Goals;assists;tackles;total_passes;passes_done;total_duels;duels_won;total_ground_duels;ground_duels_won;total_aerial_duels;aerial_duels_won;minutes_played;shots_on_target;shots_off_target;shots_blocked;total_dribble;dribble_done;position;rating;bcm;hw;pw;pm;possession_lost;fouls;was_fouled;offsides;date_acquisition");');
|
||||
|
||||
Notification::make()
|
||||
->title('Header copied successfully')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class UbEventForm
|
||||
@@ -10,7 +14,81 @@ class UbEventForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
Section::make('Player Team')
|
||||
->schema([
|
||||
Radio::make('home_away')
|
||||
->hiddenLabel()
|
||||
->options([
|
||||
'H' => 'Home',
|
||||
'A' => 'Away',
|
||||
]),
|
||||
TextInput::make('rating')
|
||||
->numeric()
|
||||
->inputMode('decimal'),
|
||||
])->columns(2),
|
||||
Grid::make([
|
||||
'default' => 2,
|
||||
'md' => 3,
|
||||
'xl' => 5,
|
||||
])
|
||||
->schema([
|
||||
TextInput::make('home_ft'),
|
||||
TextInput::make('away_ft'),
|
||||
TextInput::make('home_ht'),
|
||||
TextInput::make('away_ht'),
|
||||
TextInput::make('goals'),
|
||||
TextInput::make('assists'),
|
||||
TextInput::make('tackles'),
|
||||
TextInput::make('total_passes'),
|
||||
TextInput::make('passes_done'),
|
||||
TextInput::make('total_duels'),
|
||||
TextInput::make('duels_won'),
|
||||
TextInput::make('total_ground_duels'),
|
||||
TextInput::make('ground_duels_won'),
|
||||
TextInput::make('total_aerial_duels'),
|
||||
TextInput::make('aerial_duels_won'),
|
||||
TextInput::make('minutes_played'),
|
||||
TextInput::make('shots_on_target'),
|
||||
TextInput::make('shots_off_target'),
|
||||
TextInput::make('shots_blocked'),
|
||||
TextInput::make('total_dribble'),
|
||||
TextInput::make('dribble_done'),
|
||||
TextInput::make('position'),
|
||||
TextInput::make('bcm'),
|
||||
TextInput::make('hw'),
|
||||
TextInput::make('pw'),
|
||||
TextInput::make('pm'),
|
||||
TextInput::make('possession_lost'),
|
||||
TextInput::make('fouls'),
|
||||
TextInput::make('was_fouled'),
|
||||
TextInput::make('offsides'),
|
||||
]),
|
||||
|
||||
])->columns(1);
|
||||
}
|
||||
}
|
||||
// 'total_passes',
|
||||
// 'passes_done',
|
||||
// 'total_duels',
|
||||
// 'duels_won',
|
||||
// 'total_ground_duels',
|
||||
// 'ground_duels_won',
|
||||
// 'total_aerial_duels',
|
||||
// 'aerial_duels_won',
|
||||
// 'minutes_played',
|
||||
// 'shots_on_target',
|
||||
// 'shots_off_target',
|
||||
// 'shots_blocked',
|
||||
// 'total_dribble',
|
||||
// 'dribble_done',
|
||||
// 'position',
|
||||
// 'rating',
|
||||
// 'bcm',
|
||||
// 'hw',
|
||||
// 'pw',
|
||||
// 'pm',
|
||||
// 'possession_lost',
|
||||
// 'fouls',
|
||||
// 'was_fouled',
|
||||
// 'offsides',
|
||||
// 'date_acquisition',
|
||||
@@ -5,27 +5,65 @@ namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Tables;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class UbEventsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->poll('10sec')
|
||||
->columns([
|
||||
// TextColumn::make('league_id')->searchable(),
|
||||
TextColumn::make('starttime')->dateTime('d. M. Y')->label('Date'),
|
||||
TextColumn::make('league.name')->searchable(),
|
||||
// TextColumn::make('home_id')->searchable(),
|
||||
// TextColumn::make('away_id')->searchable(),
|
||||
TextColumn::make('home.name')->searchable(),
|
||||
TextColumn::make('away.name')->searchable(),
|
||||
TextColumn::make('player_id')->searchable(),
|
||||
TextColumn::make('player.name')->searchable(),
|
||||
TextColumn::make('starttime')->dateTime('d. M. Y')->label('Date'),
|
||||
TextColumn::make('rating'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
Filter::make('created_at')
|
||||
->columns(2)->columnSpanFull()
|
||||
->schema([
|
||||
DatePicker::make('from'),
|
||||
DatePicker::make('until'),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['from'],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate('starttime', '>=', $date),
|
||||
)
|
||||
->when(
|
||||
$data['until'],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate('starttime', '<=', $date),
|
||||
);
|
||||
})
|
||||
->indicateUsing(function (array $data): array {
|
||||
$indicators = [];
|
||||
|
||||
if ($data['from'] ?? null) {
|
||||
$indicators[] = Indicator::make('Starttime from '.Carbon::parse($data['from'])->toFormattedDateString())
|
||||
->removeField('from');
|
||||
}
|
||||
|
||||
if ($data['until'] ?? null) {
|
||||
$indicators[] = Indicator::make('Starttime until '.Carbon::parse($data['until'])->toFormattedDateString())
|
||||
->removeField('until');
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
|
||||
@@ -11,6 +11,7 @@ use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class UbEventResource extends Resource
|
||||
{
|
||||
@@ -18,11 +19,16 @@ class UbEventResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'icon-soccerball';
|
||||
|
||||
protected static ?string $navigationLabel = 'Events';
|
||||
protected static ?string $navigationLabel = 'Events & Player';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'league_id';
|
||||
// protected static ?string $recordTitleAttribute = 'league_id';
|
||||
|
||||
public static function getRecordTitle($record): string|null|Htmlable
|
||||
{
|
||||
return ': '.$record->starttime->format('d. M. Y').' - '.$record->league->name.' - '.$record->home->name.' vs '.$record->away->name.' - '.$record->player->name;
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user