filter playeer played
This commit is contained in:
1 parent
74e9285bac
commit
5081ec9e32
30 files changed
+4114
-1420
No files matched your search
-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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSofaScoreDay extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SofaScoreDayResource::class;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSofaScoreDay extends EditRecord
|
||||
{
|
||||
protected static string $resource = SofaScoreDayResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreDays\SofaScoreDayResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSofaScoreDays extends ListRecords
|
||||
{
|
||||
protected static string $resource = SofaScoreDayResource::class;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SofaScoreDayForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\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\Models\SofaScoreDay;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class SofaScoreDayResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SofaScoreDay::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'Days';
|
||||
|
||||
protected static ?string $navigationLabel = 'Days';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SofaScoreDayForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return SofaScoreDaysTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListSofaScoreDays::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Tables;
|
||||
|
||||
use App\Models\SofaScoreDay;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
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 SofaScoreDaysTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->description('For days checked events active in tournaments will be grapped.')
|
||||
->headerActions([
|
||||
Action::make('generate')->icon('phosphor-calendar')
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->options(Sport::where('is_active', 1)
|
||||
->pluck('name', 'id'))
|
||||
->required(),
|
||||
Select::make('year')
|
||||
->options(self::years())
|
||||
->required(),
|
||||
Select::make('month')
|
||||
->options(self::month())
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data, $table): void {
|
||||
$sport_id = $data['sport_id'];
|
||||
$date = Carbon::createFromDate($data['year'], $data['month'], 1)->startOfMonth();
|
||||
$daysCount = $date->daysInMonth;
|
||||
|
||||
$allDates = [];
|
||||
for ($i = 1; $i <= $daysCount; $i++) {
|
||||
$allDates[] = $date->copy()->day($i)->format('Y-m-d');
|
||||
}
|
||||
foreach ($allDates as $day) {
|
||||
SofaScoreDay::updateOrCreate(['day' => $day, 'sport_id' => $sport_id]);
|
||||
}
|
||||
}),
|
||||
Action::make('reset')
|
||||
->icon('phosphor-power')
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->options(Sport::where('is_active', 1)
|
||||
->pluck('name', 'id'))
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$sport_id = $data['sport_id'];
|
||||
SofaScoreDay::where('sport_id', $sport_id)->update(['enabled' => 0]);
|
||||
}),
|
||||
])
|
||||
->columns([
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('day')->sortable(),
|
||||
ToggleColumn::make('enabled'),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('filter')
|
||||
->columns(4)->columnSpan(4)
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->default(1)
|
||||
->selectablePlaceholder(false)
|
||||
->label('Sport')
|
||||
->options(Sport::where('is_active', 1)->pluck('name', 'id')),
|
||||
Select::make('year')->options(self::years()),
|
||||
Select::make('month')->options(self::month()),
|
||||
Toggle::make('enabled'),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['year'],
|
||||
fn (Builder $query, $year): Builder => $query->whereYear('day', $year),
|
||||
)->when(
|
||||
$data['month'],
|
||||
fn (Builder $query, $month): Builder => $query->whereMonth('day', $month),
|
||||
)->when(
|
||||
$data['enabled'],
|
||||
fn (Builder $query, $enabled): Builder => $query->where('enabled', $enabled),
|
||||
);
|
||||
})->indicateUsing(function (array $data): array {
|
||||
$indicators = [];
|
||||
if ($data['year'] ?? null) {
|
||||
$indicators[] = Indicator::make('Year: '.$data['year']);
|
||||
}
|
||||
if ($data['month'] ?? null) {
|
||||
$indicators[] = Indicator::make('Month: '.$data['month']);
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->persistFiltersInSession()
|
||||
->deferFilters(false);
|
||||
}
|
||||
|
||||
public static function years()
|
||||
{
|
||||
$years = range(date('Y'), date('Y') - 10);
|
||||
|
||||
return array_combine($years, $years);
|
||||
}
|
||||
|
||||
public static function month()
|
||||
{
|
||||
$months = [];
|
||||
for ($m = 1; $m <= 12; $m++) {
|
||||
$date = Carbon::create(null, $m, 1);
|
||||
$months[$date->format('m')] = $date->format('F');
|
||||
}
|
||||
|
||||
return $months;
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSofaScoreTournament extends CreateRecord
|
||||
{
|
||||
protected static string $resource = SofaScoreTournamentResource::class;
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSofaScoreTournament extends EditRecord
|
||||
{
|
||||
protected static string $resource = SofaScoreTournamentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSofaScoreTournaments extends ListRecords
|
||||
{
|
||||
protected static string $resource = SofaScoreTournamentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
// CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SofaScoreTournamentForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\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\Models\SofaScoreTournament;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Livewire\Livewire;
|
||||
use UnitEnum;
|
||||
|
||||
class SofaScoreTournamentResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SofaScoreTournament::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'Tournaments';
|
||||
|
||||
protected static ?string $navigationLabel = 'Tournaments';
|
||||
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SofaScoreTournamentForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return SofaScoreTournamentsTable::configure($table);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListSofaScoreTournaments::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
-217
@@ -1,217 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables;
|
||||
|
||||
use App\Models\SofaScoreCategorie;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class SofaScoreTournamentsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->headerActions([
|
||||
Action::make('grapping')
|
||||
->icon('phosphor-power')
|
||||
->tooltip('Will stop grapping for selected sport')
|
||||
->schema([
|
||||
Select::make('sport')
|
||||
->options(Sport::where('is_active', 1)
|
||||
->pluck('name', 'id'))
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$sport_id = $data['sport_id'];
|
||||
SofaScoreTournament::where('sport_id', $sport_id)->update(['enabled' => 0]);
|
||||
}),
|
||||
Action::make('disabled')
|
||||
->icon('phosphor-power')
|
||||
->tooltip('Will activate all disabled leagues for selected sport')
|
||||
->schema([
|
||||
Select::make('sport')
|
||||
->options(Sport::where('is_active', 1)
|
||||
->pluck('name', 'id'))
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$sport_id = $data['sport_id'];
|
||||
SofaScoreTournament::where('sport_id', $sport_id)->update(['disabled' => 0]);
|
||||
}),
|
||||
])
|
||||
->poll()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->grow(false)
|
||||
->width(30)
|
||||
->color(fn ($record) => $record->sport->color)
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->size(IconSize::Medium)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
TextColumn::make('tournament_id')->sortable()->searchable(),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('sofascore_category.name')
|
||||
->icon(fn ($record) => $record->sofascore_category->country->icon),
|
||||
TextColumn::make('name')->searchable()->sortable(),
|
||||
ToggleColumn::make('enabled')->label('Enable'),
|
||||
ToggleColumn::make('disabled')->label('Disable'),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('filters')
|
||||
->columns(7)->columnSpan(7)
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->default(1)
|
||||
->selectablePlaceholder(false)
|
||||
->label('Sport')
|
||||
->options(Sport::where('is_active', 1)->pluck('name', 'id'))
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('sofa_score_categorie_id', null);
|
||||
})
|
||||
->live(),
|
||||
Select::make('sofa_score_categorie_id')
|
||||
->searchable()
|
||||
->multiple()
|
||||
->columnSpan(2)
|
||||
->label('Categorie')
|
||||
->options(function (Get $get) {
|
||||
$res = SofaScoreTournament::where('sport_id', $get('sport_id'))
|
||||
->groupBy('sofa_score_categorie_id')
|
||||
->pluck('sofa_score_categorie_id')
|
||||
->toArray();
|
||||
|
||||
return SofaScoreCategorie::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
})
|
||||
->live(),
|
||||
ToggleButtons::make('filter-grapping')
|
||||
->inline()
|
||||
->columnSpan(2)
|
||||
->default('active')
|
||||
->options([
|
||||
'all' => 'All',
|
||||
'active' => 'Active',
|
||||
'disabled' => 'Disabled',
|
||||
]),
|
||||
ToggleButtons::make('filter-disabled')
|
||||
->inline()
|
||||
->columnSpan(2)
|
||||
->default('active')
|
||||
->options([
|
||||
'all' => 'All',
|
||||
'active' => 'Active',
|
||||
'hidden' => 'Hidden',
|
||||
]),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['sport_id'],
|
||||
fn (Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
|
||||
)->when(
|
||||
$data['sofa_score_categorie_id'],
|
||||
function (Builder $query, $sofa_score_categorie_id) {
|
||||
if (is_array($sofa_score_categorie_id)) {
|
||||
$query->whereIn('sofa_score_categorie_id', $sofa_score_categorie_id);
|
||||
} else {
|
||||
$query->where('sofa_score_categorie_id', $sofa_score_categorie_id);
|
||||
}
|
||||
}
|
||||
)->when(
|
||||
$data['filter-grapping'],
|
||||
function (Builder $query, $filtergrapping) {
|
||||
switch ($filtergrapping) {
|
||||
case 'active':
|
||||
$query->where('enabled', 1);
|
||||
break;
|
||||
case 'disabled':
|
||||
$query->where('enabled', 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
)->when(
|
||||
$data['filter-disabled'],
|
||||
function (Builder $query, $filterdisabled) {
|
||||
switch ($filterdisabled) {
|
||||
case 'active':
|
||||
$query->where('disabled', 0);
|
||||
break;
|
||||
case 'hidden':
|
||||
$query->where('disabled', 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('Enable')
|
||||
->icon('phosphor-toggle-right-fill')
|
||||
->color('primary')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
SofaScoreTournament::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) {
|
||||
SofaScoreTournament::where('id', '=', $record->id)
|
||||
->update(
|
||||
['enabled' => 0]
|
||||
);
|
||||
}
|
||||
}),
|
||||
])->label('Grapping'),
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('Hide')
|
||||
->icon('phosphor-toggle-right-fill')
|
||||
->color('primary')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
SofaScoreTournament::where('id', '=', $record->id)
|
||||
->update(
|
||||
['disabled' => 1]
|
||||
);
|
||||
}
|
||||
}),
|
||||
BulkAction::make('Show')
|
||||
->icon('phosphor-toggle-left-fill')
|
||||
->color('gray')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
SofaScoreTournament::where('id', '=', $record->id)
|
||||
->update(
|
||||
['disabled' => 0]
|
||||
);
|
||||
}
|
||||
}),
|
||||
])->label('Disabled'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user