remove days and add tasks
This commit is contained in:
1 parent
be2a16a812
commit
23a367c493
31 files changed
+237
-464
No files matched your search
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\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\Grapper\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\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\Grapper\Resources\SofaScoreDays\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\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\Grapper\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\Grapper\Resources\SofaScoreDays;
|
||||
|
||||
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;
|
||||
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 = GrapperCluster::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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
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\Database\Eloquent\Collection;
|
||||
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)
|
||||
->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()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers\SofaScoreTaskTournamentsRelationManager;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\SofaScoreTaskResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Guava\FilamentModalRelationManagers\Actions\RelationManagerAction;
|
||||
|
||||
class EditSofaScoreTask extends EditRecord
|
||||
{
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers\SofaScoreTaskTournamentsRelationManager;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\SofaScoreTaskResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Guava\FilamentModalRelationManagers\Actions\RelationManagerAction;
|
||||
|
||||
class ListSofaScoreTasks extends ListRecords
|
||||
{
|
||||
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers;
|
||||
|
||||
use App\Models\SofaScoreCategorie;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class SofaScoreTaskTournamentsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'sofa_score_task_tournaments';
|
||||
|
||||
protected static ?string $title = 'Tournaments';
|
||||
|
||||
protected static ?string $navigationLabel = 'Tournaments';
|
||||
|
||||
protected static ?string $modelLabel = 'Tournament';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Tournaments';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('sofa_score_categorie_id')
|
||||
->searchable()
|
||||
->label('Categorie')
|
||||
->options(function (Get $get) {
|
||||
$res = SofaScoreTournament::where('sport_id', $this->getOwnerRecord()['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(),
|
||||
Select::make('sofa_score_tournament_id')
|
||||
->searchable()
|
||||
->label('Tournament')
|
||||
->options(fn (Get $get) => SofaScoreTournament::where('sport_id', $this->getOwnerRecord()['sport_id'])
|
||||
->where('disabled', 0)
|
||||
->where('sofa_score_categorie_id', $get('sofa_score_categorie_id'))
|
||||
->pluck('name', 'tournament_id')),
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('tournament.sofascore_category.name')
|
||||
->label('Country')
|
||||
->searchable(),
|
||||
TextColumn::make('tournament.name')
|
||||
->weight(FontWeight::Bold)
|
||||
->searchable(),
|
||||
ToggleColumn::make('disabled')
|
||||
->alignCenter(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->icon('phosphor-plus')
|
||||
->label('Tournament'),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+2
@@ -31,9 +31,11 @@ class SofaScoreTaskForm
|
||||
'range' => '<span class="text-green-600">Grap a date range</span>',
|
||||
]),
|
||||
DatePicker::make('day_from')
|
||||
->required()
|
||||
->native()
|
||||
->visible(fn (Get $get): bool => in_array($get('mode'), ['date', 'range'])),
|
||||
DatePicker::make('day_to')
|
||||
->required()
|
||||
->native()
|
||||
->visible(fn (Get $get): bool => $get('mode') === 'range'),
|
||||
]);
|
||||
|
||||
@@ -22,9 +22,9 @@ class SofaScoreTaskResource extends Resource
|
||||
|
||||
protected static ?string $modelLabel = 'SofaScore Tasks';
|
||||
|
||||
protected static ?int $navigationSort = 0;
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -36,13 +36,6 @@ class SofaScoreTaskResource extends Resource
|
||||
return SofaScoreTasksTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
|
||||
+33
-11
@@ -2,11 +2,16 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Tables;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers\SofaScoreTaskTournamentsRelationManager;
|
||||
use App\Models\SofaScoreTask;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Guava\FilamentModalRelationManagers\Actions\RelationManagerAction;
|
||||
|
||||
class SofaScoreTasksTable
|
||||
{
|
||||
@@ -20,29 +25,46 @@ class SofaScoreTasksTable
|
||||
->width(30)
|
||||
->icon(fn ($record) => $record->sport->icon),
|
||||
TextColumn::make('sport.name'),
|
||||
IconColumn::make('compleated')
|
||||
->width('1rem')
|
||||
->label('Status')
|
||||
->alignCenter()
|
||||
->icon(fn (string $state): string => match ($state) {
|
||||
'0' => 'phosphor-pause-fill',
|
||||
'1' => 'phosphor-check-fat-fill',
|
||||
})
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'0' => 'gray',
|
||||
'1' => 'success',
|
||||
}),
|
||||
TextColumn::make('mode')
|
||||
->label('Grapping dates')
|
||||
->badge()
|
||||
->color(fn ($state): string => match ($state) {
|
||||
'yesterday' => 'warning',
|
||||
'date' => 'primary',
|
||||
'range' => 'success',
|
||||
})
|
||||
->formatStateUsing(fn (string $state, $record): string => match ($state) {
|
||||
'yesterday' => 'Every yesterday',
|
||||
'date' => $record->day_from->format('Y-m-d'),
|
||||
'range' => $record->day_from.' - '.$record->day_to,
|
||||
'date' => $record->day_from,
|
||||
'range' => $record->day_from.' <=> '.$record->day_to,
|
||||
}),
|
||||
ToggleColumn::make('is_active')
|
||||
->alignCenter()
|
||||
->afterStateUpdated(function ($record) {
|
||||
SofaScoreTask::where('id', $record->id)->update(['compleated' => 0]);
|
||||
}),
|
||||
ToggleColumn::make('is_active')->alignCenter(),
|
||||
ToggleColumn::make('run_slow')->alignCenter(),
|
||||
ToggleColumn::make('run_repeatedly')->alignCenter(),
|
||||
ToggleColumn::make('compleated')->alignCenter(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
RelationManagerAction::make()
|
||||
->icon('phosphor-trophy-fill')
|
||||
->iconButton()
|
||||
->modalHeading('Add tournaments to sofascore grapper task')
|
||||
->relationManager(SofaScoreTaskTournamentsRelationManager::make())
|
||||
->compact(),
|
||||
EditAction::make()->iconButton()
|
||||
->icon('phosphor-calendar-fill'),
|
||||
DeleteAction::make()->iconButton(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages;
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateSofaScoreTournament extends CreateRecord
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages;
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Pages;
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages;
|
||||
|
||||
use App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Schemas;
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
+7
-6
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments;
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments;
|
||||
|
||||
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\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;
|
||||
@@ -19,12 +19,13 @@ class SofaScoreTournamentResource extends Resource
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected static ?string $cluster = GrapperCluster::class;
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'Tournaments';
|
||||
|
||||
protected static ?string $navigationLabel = 'Tournaments';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
+11
-43
@@ -1,17 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Grapper\Resources\SofaScoreTournaments\Tables;
|
||||
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;
|
||||
@@ -29,35 +26,6 @@ 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('')
|
||||
@@ -73,7 +41,7 @@ class SofaScoreTournamentsTable
|
||||
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('enabled')->label('Enable'),
|
||||
ToggleColumn::make('disabled')->label('Disable'),
|
||||
])
|
||||
->filters([
|
||||
@@ -103,15 +71,15 @@ class SofaScoreTournamentsTable
|
||||
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-grapping')
|
||||
// ->inline()
|
||||
// ->columnSpan(2)
|
||||
// ->default('active')
|
||||
// ->options([
|
||||
// 'all' => 'All',
|
||||
// 'active' => 'Active',
|
||||
// 'disabled' => 'Disabled',
|
||||
// ]),
|
||||
ToggleButtons::make('filter-disabled')
|
||||
->inline()
|
||||
->columnSpan(2)
|
||||
Reference in new issue
Block a user