wip
This commit is contained in:
1 parent
8c235ef82c
commit
acf74c5e82
8 files changed
+593
-90
No files matched your search
+1
-1
@@ -13,7 +13,7 @@ class EditSofaScoreRosa extends EditRecord
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
// DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+42
-68
@@ -2,89 +2,63 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreRosas\Tables;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Models\Sport;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class SofaScoreRosasTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->description('The squad for the team selected will be send next day via mail. The selection will be unset after sending.')
|
||||
->columns([
|
||||
TextColumn::make('ssteam_id')->label('Id')->badge()->width('1rem'),
|
||||
TextColumn::make('ssteam_id')->label('SSId')->badge()->width('1rem'),
|
||||
TextColumn::make('country.name')->label('Country'),
|
||||
TextColumn::make('tournament.name')->label('Tournament'),
|
||||
TextColumn::make('ssteam_name')->label('Name'),
|
||||
ToggleColumn::make('is_active'),
|
||||
TextColumn::make('updated_at')->dateTime('Y-m-d H:i:s')
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('country_id')
|
||||
->searchable()
|
||||
->label('Country')
|
||||
->options(function () {
|
||||
$res = SofaScoreRosa::groupBy('country_id')->pluck('country_id')->toArray();
|
||||
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
Filter::make('filters')
|
||||
->columns(3)->columnSpan(3)
|
||||
->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('ss_tournament_id', null);
|
||||
})
|
||||
->live(),
|
||||
Select::make('ss_tournament_id')
|
||||
->label('Tournament')
|
||||
->options(function (Get $get) {
|
||||
$res = SofaScoreTournament::with('sofascore_category')->where('enabled', 1)->where('sport_id', $get('sport_id'))->get();
|
||||
$return = [];
|
||||
foreach ($res as $value) {
|
||||
$return[$value->tournament_id] = $value->sofascore_category->name . ' ' . $value->name;
|
||||
}
|
||||
return $return;
|
||||
})
|
||||
->live(),
|
||||
])
|
||||
->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['ss_tournament_id'],
|
||||
fn(Builder $query, $ss_tournament_id) => $query->where('ss_tournament_id', $ss_tournament_id)
|
||||
);
|
||||
}),
|
||||
TernaryFilter::make('is_active'),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->headerActions([
|
||||
Action::make('all_on')
|
||||
->icon('phosphor-toggle-right-fill')
|
||||
->action(function (): void {
|
||||
SofaScoreRosa::query()->update(['is_active' => 1]);
|
||||
}),
|
||||
Action::make('all_off')
|
||||
->icon('phosphor-toggle-left-fill')
|
||||
->color('danger')
|
||||
->action(function (): void {
|
||||
SofaScoreRosa::query()->update(['is_active' => 0]);
|
||||
}),
|
||||
CreateAction::make()
|
||||
->icon('phosphor-plus')
|
||||
->label('Team'),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('Enable selected')
|
||||
->color('primary')
|
||||
->icon('phosphor-toggle-right-fill')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
SofaScoreRosa::where('id', '=', $record->id)
|
||||
->update(
|
||||
['is_active' => 1]
|
||||
);
|
||||
}
|
||||
}),
|
||||
BulkAction::make('Disable selected')
|
||||
->icon('phosphor-toggle-left-fill')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
SofaScoreRosa::where('id', '=', $record->id)
|
||||
->update(
|
||||
['is_active' => 0]
|
||||
);
|
||||
}
|
||||
}),
|
||||
|
||||
// DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
->deferFilters(false);
|
||||
}
|
||||
}
|
||||
+9
-5
@@ -7,7 +7,6 @@ use App\Models\SofaScoreTournament;
|
||||
use App\Models\Sport;
|
||||
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;
|
||||
@@ -34,16 +33,21 @@ class SofaScoreTournamentsTable
|
||||
->size(IconSize::Medium)
|
||||
->tooltip(fn($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('sport.name')
|
||||
->sortable(),
|
||||
TextColumn::make('tournament_id')
|
||||
->label('Id')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('sofascore_category.name')
|
||||
->icon(fn($record) => $record->sofascore_category->country->icon),
|
||||
->label('Country')
|
||||
->icon(fn($record) => $record->sofascore_category->country->icon)
|
||||
->sortable(),
|
||||
TextColumn::make('name')->searchable()->sortable(),
|
||||
ToggleColumn::make('enabled')->label('In Statistiko')->alignCenter(),
|
||||
// ToggleColumn::make('disabled')->label('Hidden'),
|
||||
ToggleColumn::make('enabled')
|
||||
->label('In Statistiko')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('filters')
|
||||
|
||||
Reference in new issue
Block a user