wip
This commit is contained in:
1 parent
c6b2602564
commit
d6a13837c5
5 files changed
+103
-36
No files matched your search
+69
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\RelationManagers;
|
||||||
|
|
||||||
|
// use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\SofaScoreTournamentResource;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||||
|
use App\Models\SofaScoreRosa;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Resources\RelationManagers\RelationManager;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Columns\ToggleColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class SofaScoreTournamentsTeamRelationManager extends RelationManager
|
||||||
|
{
|
||||||
|
protected static string $relationship = 'rosa_tournament';
|
||||||
|
|
||||||
|
// protected static ?string $relatedResource = SofaScoreTournamentResource::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = StaticDataCluster::class;
|
||||||
|
|
||||||
|
protected static ?string $title = 'Tournament Teams';
|
||||||
|
|
||||||
|
protected static ?string $navigationLabel = 'Tournament Teams';
|
||||||
|
|
||||||
|
protected static ?string $modelLabel = 'Tournament Teams';
|
||||||
|
|
||||||
|
protected static ?string $pluralModelLabel = 'Tournament Teams';
|
||||||
|
|
||||||
|
public function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Select::make('ss_team_id')
|
||||||
|
->searchable()
|
||||||
|
->label('Team')
|
||||||
|
->options(function () {
|
||||||
|
return SofaScoreRosa::query()->orderBy('ss_team_name')->pluck('ss_team_name', 'ss_team_id');
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('ss_tournament_id'),
|
||||||
|
TextColumn::make('tournament.name')->badge(),
|
||||||
|
TextColumn::make('ss_team_id'),
|
||||||
|
TextColumn::make('team.ss_team_name')->color('success'),
|
||||||
|
ToggleColumn::make('disabled'),
|
||||||
|
])
|
||||||
|
->striped()
|
||||||
|
->paginated(false)
|
||||||
|
->recordActions([
|
||||||
|
DeleteAction::make()
|
||||||
|
->iconButton(),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
CreateAction::make('Add')
|
||||||
|
->label('Add Team')
|
||||||
|
->icon('phosphor-plus'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments;
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages\EditSofaScoreTournament;
|
||||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages\ListSofaScoreTournaments;
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Pages\ListSofaScoreTournaments;
|
||||||
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\RelationManagers\SofaScoreTournamentsTeamRelationManager;
|
||||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Schemas\SofaScoreTournamentForm;
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Schemas\SofaScoreTournamentForm;
|
||||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables\SofaScoreTournamentsTable;
|
use App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables\SofaScoreTournamentsTable;
|
||||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||||
@@ -27,6 +29,9 @@ class SofaScoreTournamentResource extends Resource
|
|||||||
|
|
||||||
protected static ?int $navigationSort = 2;
|
protected static ?int $navigationSort = 2;
|
||||||
|
|
||||||
|
// Choose where you want the submenu to appear:
|
||||||
|
// SubNavigationPosition::Start (Left Sidebar) or SubNavigationPosition::Top (Horizontal Tabs)
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return SofaScoreTournamentForm::configure($schema);
|
return SofaScoreTournamentForm::configure($schema);
|
||||||
@@ -59,6 +64,15 @@ class SofaScoreTournamentResource extends Resource
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'index' => ListSofaScoreTournaments::route('/'),
|
'index' => ListSofaScoreTournaments::route('/'),
|
||||||
|
'edit' => EditSofaScoreTournament::route('/{record}/edit'),
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
SofaScoreTournamentsTeamRelationManager::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
-36
@@ -2,16 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables;
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables;
|
||||||
|
|
||||||
use App\Models\SofaScoreRosa;
|
use Filament\Actions\EditAction;
|
||||||
use App\Models\SofaScoreRosaTournament;
|
|
||||||
use App\Models\SofaScoreTournament;
|
|
||||||
use Filament\Actions\Action;
|
|
||||||
use Filament\Forms\Components\Toggle;
|
use Filament\Forms\Components\Toggle;
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Filament\Support\Enums\IconSize;
|
use Filament\Support\Enums\IconSize;
|
||||||
use Filament\Tables\Columns\IconColumn;
|
use Filament\Tables\Columns\IconColumn;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Columns\TextInputColumn;
|
|
||||||
use Filament\Tables\Columns\ToggleColumn;
|
use Filament\Tables\Columns\ToggleColumn;
|
||||||
use Filament\Tables\Enums\FiltersLayout;
|
use Filament\Tables\Enums\FiltersLayout;
|
||||||
use Filament\Tables\Filters\Filter;
|
use Filament\Tables\Filters\Filter;
|
||||||
@@ -23,31 +18,6 @@ class SofaScoreTournamentsTable
|
|||||||
public static function configure(Table $table): Table
|
public static function configure(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->headerActions([
|
|
||||||
Action::make('update_rose_tornaments')
|
|
||||||
->label('Update Roosters')
|
|
||||||
->action(function () {
|
|
||||||
$res = SofaScoreTournament::whereNotNull('ss_liga_code')->where('ss_liga_code', '<>', '')->where('enabled', 1)->pluck('ss_liga_code', 'tournament_id');
|
|
||||||
|
|
||||||
foreach ($res as $tournament_id => $ss_liga_code) {
|
|
||||||
SofaScoreRosaTournament::where('ss_tournament_id', $tournament_id)->update(['grapped' => 0, 'disabled' => 1]);
|
|
||||||
|
|
||||||
$rosa = SofaScoreRosa::where('cc', $ss_liga_code)->where('is_active', 1)->get();
|
|
||||||
|
|
||||||
foreach ($rosa as $team) {
|
|
||||||
SofaScoreRosaTournament::updateOrCreate(
|
|
||||||
['ss_team_id' => $team->ss_team_id, 'ss_tournament_id' => $tournament_id],
|
|
||||||
['disabled' => 0]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->successNotification(
|
|
||||||
Notification::make()
|
|
||||||
->success()
|
|
||||||
->title('Tournament Roosters table updated')
|
|
||||||
),
|
|
||||||
])
|
|
||||||
->columns([
|
->columns([
|
||||||
IconColumn::make('sport.icon')
|
IconColumn::make('sport.icon')
|
||||||
->label('')
|
->label('')
|
||||||
@@ -69,10 +39,10 @@ class SofaScoreTournamentsTable
|
|||||||
->searchable()
|
->searchable()
|
||||||
->icon(fn ($record) => $record->sofascore_category->flag)
|
->icon(fn ($record) => $record->sofascore_category->flag)
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextInputColumn::make('ss_liga_code')
|
// TextInputColumn::make('ss_liga_code')
|
||||||
->label('SofaScore Liga Code')
|
// ->label('SofaScore Liga Code')
|
||||||
->searchable()
|
// ->searchable()
|
||||||
->sortable(),
|
// ->sortable(),
|
||||||
TextColumn::make('name')
|
TextColumn::make('name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -98,6 +68,10 @@ class SofaScoreTournamentsTable
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
], layout: FiltersLayout::AboveContent)
|
], layout: FiltersLayout::AboveContent)
|
||||||
->deferFilters(false);
|
->deferFilters(false)
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make()
|
||||||
|
->iconButton(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,4 +21,9 @@ class SofaScoreRosaTournament extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(SofaScoreTournament::class, 'ss_tournament_id', 'tournament_id');
|
return $this->belongsTo(SofaScoreTournament::class, 'ss_tournament_id', 'tournament_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function team()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(SofaScoreRosa::class, 'ss_team_id', 'ss_team_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,4 +31,9 @@ class SofaScoreTournament extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(SofaScoreCategory::class, 'sofa_score_category_id', 'id');
|
return $this->belongsTo(SofaScoreCategory::class, 'sofa_score_category_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function rosa_tournament()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(SofaScoreRosaTournament::class, 'tournament_id', 'ss_tournament_id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user