filter playeer played
This commit is contained in:
1 parent
74e9285bac
commit
5081ec9e32
30 files changed
+4114
-1420
No files matched your search
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSofaScoreDay extends CreateRecord
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSofaScoreDays extends ListRecords
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Schemas;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages\ListSofaScoreDays;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Schemas\SofaScoreDayForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Tables\SofaScoreDaysTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Filament\Clusters\Grapper\GrapperCluster;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Pages\ListSofaScoreDays;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Schemas\SofaScoreDayForm;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Tables\SofaScoreDaysTable;
|
||||
use App\Models\SofaScoreDay;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -22,7 +22,7 @@ class SofaScoreDayResource extends Resource
|
||||
|
||||
protected static ?string $navigationLabel = 'Days';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
protected static ?string $cluster = GrapperCluster::class;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
+31
-2
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Tables;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Tables;
|
||||
|
||||
use App\Models\SofaScoreDay;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
@@ -14,6 +16,7 @@ use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class SofaScoreDaysTable
|
||||
@@ -104,7 +107,33 @@ class SofaScoreDaysTable
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->persistFiltersInSession()
|
||||
->deferFilters(false);
|
||||
->deferFilters(false)
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('Enable')
|
||||
->icon('phosphor-toggle-right-fill')
|
||||
->color('primary')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
SofaScoreDay::where('id', '=', $record->id)
|
||||
->update(
|
||||
['enabled' => 1]
|
||||
);
|
||||
}
|
||||
}),
|
||||
BulkAction::make('Disable')
|
||||
->icon('phosphor-toggle-left-fill')
|
||||
->color('gray')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
SofaScoreDay::where('id', '=', $record->id)
|
||||
->update(
|
||||
['enabled' => 0]
|
||||
);
|
||||
}
|
||||
}),
|
||||
])->label('Grapping Day'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function years()
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSofaScoreTournament extends CreateRecord
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Schemas;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages\ListSofaScoreTournaments;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Schemas\SofaScoreTournamentForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables\SofaScoreTournamentsTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Filament\Clusters\Grapper\GrapperCluster;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages\ListSofaScoreTournaments;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Schemas\SofaScoreTournamentForm;
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Tables\SofaScoreTournamentsTable;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -19,7 +19,7 @@ class SofaScoreTournamentResource extends Resource
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
protected static ?string $cluster = GrapperCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'Tournaments';
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables;
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Tables;
|
||||
|
||||
use App\Models\SofaScoreCategorie;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\SofaScoreDayTournamentResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSofaScoreDayTournament extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SofaScoreDayTournamentResource::class;
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\SofaScoreDayTournamentResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSofaScoreDayTournament extends EditRecord
|
||||
{
|
||||
protected static string $resource = SofaScoreDayTournamentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\SofaScoreDayTournamentResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSofaScoreDayTournaments extends ListRecords
|
||||
{
|
||||
protected static string $resource = SofaScoreDayTournamentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SofaScoreDayTournamentForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages\CreateSofaScoreDayTournament;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages\EditSofaScoreDayTournament;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Pages\ListSofaScoreDayTournaments;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Schemas\SofaScoreDayTournamentForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Tables\SofaScoreDayTournamentsTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Livewire\Livewire;
|
||||
use UnitEnum;
|
||||
|
||||
class SofaScoreDayTournamentResource extends Resource
|
||||
{
|
||||
protected static bool $shouldRegisterNavigation = false;
|
||||
|
||||
protected static ?string $model = SofaScoreDayTournament::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'Days & Tournaments';
|
||||
|
||||
protected static ?string $navigationLabel = 'Days & Tournaments';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SofaScoreDayTournamentForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return SofaScoreDayTournamentsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListSofaScoreDayTournaments::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
// return parent::getEloquentQuery()->count();
|
||||
// Ensure we are on the list page
|
||||
if (! class_exists(Livewire::class) || Livewire::current() === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$livewire = Livewire::current();
|
||||
|
||||
// Check if the current component has the table filtering traits
|
||||
if (method_exists($livewire, 'getFilteredTableQuery')) {
|
||||
return (string) $livewire->getFilteredTableQuery()->count();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDayTournaments\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class SofaScoreDayTournamentsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
//
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,10 @@ class Statistic extends BaseDashboard
|
||||
'all' => 'All',
|
||||
'home' => 'Home',
|
||||
'away' => 'Away',
|
||||
]),
|
||||
])->afterStateUpdated(function (callable $set) {
|
||||
// $set('team_id', null);
|
||||
$set('tm_player_id', null);
|
||||
}),
|
||||
]),
|
||||
Grid::make([
|
||||
'default' => 1,
|
||||
@@ -220,15 +223,6 @@ class Statistic extends BaseDashboard
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'primary' : '')
|
||||
->prefixIcon('icon-player')
|
||||
->suffixAction(
|
||||
Action::make('copyCostToPrice')
|
||||
->action(function (callable $set) {
|
||||
$set('tm_player_id', null);
|
||||
$set('player_on_field', null);
|
||||
})
|
||||
->color('gray')
|
||||
->icon('phosphor-x'),
|
||||
)
|
||||
->preload()
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use App\Filament\Widgets\Data\LoadEvents\LoadEventsAverages;
|
||||
use App\Models\SofaScoreEvent;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
@@ -95,9 +97,25 @@ class LoadEvents
|
||||
*/
|
||||
$matches_played = [];
|
||||
$description = '';
|
||||
// dd($tm_player_id); 613873
|
||||
|
||||
if ($tm_player_id) {
|
||||
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)
|
||||
|
||||
$matches_season = StatistikoEvent::where(function ($query) use ($team_id, $team_position) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', '=', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', '=', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
|
||||
$matches_played = StatistikoPlayer::query()
|
||||
->whereIn('match_id', $matches_season)
|
||||
->where('tm_player_id', '=', (int) $tm_player_id)
|
||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
@@ -105,16 +123,18 @@ class LoadEvents
|
||||
// 'notplayed' => 'Not Played',
|
||||
switch ($player_on_field) {
|
||||
case 'all':
|
||||
return $query->where('match_id', '>', 0);
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
case 'lineup':
|
||||
return $query->where('lineup', 'T');
|
||||
return $query->where('lineup', 'T')->where('minutes_played', '>', 0);
|
||||
case 'substituted':
|
||||
return $query->where('lineup', 'P');
|
||||
case 'notplayed':
|
||||
return $query->where('lineup', '=', '');
|
||||
return $query->where('lineup', 'P')->where('minutes_played', '>', 0);
|
||||
default:
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
}
|
||||
})
|
||||
->pluck('match_id')->toArray();
|
||||
|
||||
|
||||
$description = ' with ' . StatistikoDetail::where('tm_player_id', (int) $tm_player_id)->value('name') . ' (' . \count($matches_played) . ')';
|
||||
|
||||
if (! $matches_played) {
|
||||
|
||||
Reference in new issue
Block a user