wip
This commit is contained in:
1 parent
b25cf15a9e
commit
07e775ddf2
11 files changed
+160
-106
No files matched your search
@@ -3,17 +3,9 @@
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreRosas\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreRosas\SofaScoreRosaResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSofaScoreRosas extends ListRecords
|
||||
{
|
||||
protected static string $resource = SofaScoreRosaResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+12
-15
@@ -2,29 +2,30 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreRosas;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreRosas\Pages\CreateSofaScoreRosa;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreRosas\Pages\EditSofaScoreRosa;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreRosas\Pages\ListSofaScoreRosas;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreRosas\Schemas\SofaScoreRosaForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreRosas\Tables\SofaScoreRosasTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class SofaScoreRosaResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SofaScoreRosa::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $navigationLabel = 'Rosa';
|
||||
|
||||
protected static ?string $modelLabel = 'Rosa';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SofaScoreRosaForm::configure($schema);
|
||||
@@ -35,19 +36,15 @@ class SofaScoreRosaResource extends Resource
|
||||
return SofaScoreRosasTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListSofaScoreRosas::route('/'),
|
||||
'create' => CreateSofaScoreRosa::route('/create'),
|
||||
'edit' => EditSofaScoreRosa::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
+58
-5
@@ -2,13 +2,20 @@
|
||||
|
||||
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\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class SofaScoreRosasTable
|
||||
{
|
||||
@@ -16,19 +23,65 @@ class SofaScoreRosasTable
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('ssteam_id')->badge()->alignCenter()->width('1rem'),
|
||||
TextColumn::make('ssteam_name'),
|
||||
TextColumn::make('ssteam_id')->label('Id')->badge()->width('1rem'),
|
||||
TextColumn::make('country.name')->label('Country'),
|
||||
TextColumn::make('ssteam_name')->label('Name'),
|
||||
ToggleColumn::make('is_active'),
|
||||
])
|
||||
->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');
|
||||
})
|
||||
], 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([
|
||||
DeleteBulkAction::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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ class SofaScoreTaskForm
|
||||
->allowHtml()
|
||||
->required()
|
||||
->options([
|
||||
'auto_updater' => '<span class="text-green-600">Yesterday</span>',
|
||||
'daily' => '<span class="text-green-600">Yesterday</span>',
|
||||
'date' => '<span class="text-blue-600">Grap a date</span>',
|
||||
'range' => '<span class="text-amber-600">Grap a date range</span>',
|
||||
]),
|
||||
|
||||
@@ -20,9 +20,9 @@ class SofaScoreTaskResource extends Resource
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'SofaScore Tasks';
|
||||
protected static ?string $navigationLabel = 'Tasks';
|
||||
|
||||
protected static ?string $modelLabel = 'SofaScore Tasks';
|
||||
protected static ?string $modelLabel = 'Tasks';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ class SofaScoreTasksTable
|
||||
TextColumn::make('mode')
|
||||
->label('Grapping dates')
|
||||
->formatStateUsing(fn(string $state, $record): string => match ($state) {
|
||||
'auto_updater' => 'Yesterday',
|
||||
'daily' => 'Yesterday',
|
||||
'date' => $record->day_from,
|
||||
'range' => $record->day_from . ' <=> ' . $record->day_to,
|
||||
}),
|
||||
|
||||
+68
-68
@@ -5,21 +5,21 @@ namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables
|
||||
use App\Models\SofaScoreCategory;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
// use Filament\Actions\Action;
|
||||
// use Filament\Actions\BulkAction;
|
||||
// use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
// 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\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;
|
||||
// use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class SofaScoreTournamentsTable
|
||||
{
|
||||
@@ -41,8 +41,8 @@ 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('disabled')->label('Hidden'),
|
||||
// ToggleColumn::make('enabled')->label('Enable'),
|
||||
// ToggleColumn::make('disabled')->label('Hidden'),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('filters')
|
||||
@@ -71,15 +71,15 @@ class SofaScoreTournamentsTable
|
||||
return SofaScoreCategory::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
})
|
||||
->live(),
|
||||
ToggleButtons::make('filter-disabled')
|
||||
->inline()
|
||||
->columnSpan(2)
|
||||
->default('active')
|
||||
->options([
|
||||
'all' => 'All',
|
||||
'enabled' => 'Enabled',
|
||||
'hidden' => 'Hidden',
|
||||
]),
|
||||
// ToggleButtons::make('filter-disabled')
|
||||
// ->inline()
|
||||
// ->columnSpan(2)
|
||||
// ->default('active')
|
||||
// ->options([
|
||||
// 'all' => 'All',
|
||||
// 'enabled' => 'Enabled',
|
||||
// 'hidden' => 'Hidden',
|
||||
// ]),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
@@ -121,56 +121,56 @@ class SofaScoreTournamentsTable
|
||||
);
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('Enable selected')
|
||||
->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 selected')
|
||||
->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 selected')
|
||||
->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 selected')
|
||||
->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('Hidden'),
|
||||
]);
|
||||
->deferFilters(false);
|
||||
// ->toolbarActions([
|
||||
// BulkActionGroup::make([
|
||||
// BulkAction::make('Enable selected')
|
||||
// ->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 selected')
|
||||
// ->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 selected')
|
||||
// ->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 selected')
|
||||
// ->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('Hidden'),
|
||||
// ]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user