new garpper tasks

This commit is contained in:
salam committed 2026-07-01 08:08:54 +02:00
1 parent c6255be910
commit be2a16a812
13 files changed
+411 -55

No files matched your search

@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages;
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\SofaScoreTaskResource;
use Filament\Resources\Pages\CreateRecord;
class CreateSofaScoreTask extends CreateRecord
{
protected static string $resource = SofaScoreTaskResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages;
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\SofaScoreTaskResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditSofaScoreTask extends EditRecord
{
protected static string $resource = SofaScoreTaskResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages;
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\SofaScoreTaskResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListSofaScoreTasks extends ListRecords
{
protected static string $resource = SofaScoreTaskResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make()
->label('New Task')
->icon('phosphor-plus')
->createAnother(false),
];
}
}
@@ -0,0 +1,41 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Schemas;
use App\Models\Sport;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
class SofaScoreTaskForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(1)
->components([
Select::make('sport_id')
->default(1)
->selectablePlaceholder(false)
->label('Sport')
->options(Sport::where('is_active', 1)->pluck('name', 'id')),
Select::make('mode')
->live()
->native()
->allowHtml()
->required()
->options([
'yesterday' => '<span class="text-amber-600">Every yesterday</span>',
'date' => '<span class="text-blue-600">Grap a date</span>',
'range' => '<span class="text-green-600">Grap a date range</span>',
]),
DatePicker::make('day_from')
->native()
->visible(fn (Get $get): bool => in_array($get('mode'), ['date', 'range'])),
DatePicker::make('day_to')
->native()
->visible(fn (Get $get): bool => $get('mode') === 'range'),
]);
}
}
@@ -0,0 +1,57 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks;
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages\ListSofaScoreTasks;
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Schemas\SofaScoreTaskForm;
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Tables\SofaScoreTasksTable;
use App\Filament\Clusters\StaticData\StaticDataCluster;
use App\Models\SofaScoreTask;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use UnitEnum;
class SofaScoreTaskResource extends Resource
{
protected static ?string $model = SofaScoreTask::class;
protected static ?string $cluster = StaticDataCluster::class;
protected static ?string $navigationLabel = 'SofaScore Tasks';
protected static ?string $modelLabel = 'SofaScore Tasks';
protected static ?int $navigationSort = 0;
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
public static function form(Schema $schema): Schema
{
return SofaScoreTaskForm::configure($schema);
}
public static function table(Table $table): Table
{
return SofaScoreTasksTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getNavigationBadge(): ?string
{
return parent::getEloquentQuery()->count();
}
public static function getPages(): array
{
return [
'index' => ListSofaScoreTasks::route('/'),
];
}
}
@@ -0,0 +1,48 @@
<?php
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Tables;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ToggleColumn;
use Filament\Tables\Table;
class SofaScoreTasksTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
IconColumn::make('sport.icon')
->label('')
->grow(false)
->width(30)
->icon(fn ($record) => $record->sport->icon),
TextColumn::make('sport.name'),
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,
}),
ToggleColumn::make('is_active')->alignCenter(),
ToggleColumn::make('run_slow')->alignCenter(),
ToggleColumn::make('run_repeatedly')->alignCenter(),
ToggleColumn::make('compleated')->alignCenter(),
])
->filters([
//
])
->recordActions([
EditAction::make(),
]);
}
}