wip
This commit is contained in:
1 parent
4b93848164
commit
20e93ba014
4 files changed
+62
-14
No files matched your search
+41
-6
@@ -3,7 +3,7 @@
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\StatistikoPlayerResource;
|
||||
use App\Filament\Exports\PlayerHistoryExporter;
|
||||
use App\Filament\Exports\StatistikoPlayerExporter;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use DateTime;
|
||||
use Filament\Actions\Action;
|
||||
@@ -12,6 +12,7 @@ use Filament\Actions\ExportAction;
|
||||
use Filament\Actions\Exports\Models\Export;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListStatistikoPlayers extends ListRecords
|
||||
{
|
||||
@@ -21,12 +22,46 @@ class ListStatistikoPlayers extends ListRecords
|
||||
{
|
||||
return [
|
||||
ExportAction::make('download_players')
|
||||
->columnMapping(false)
|
||||
->chunkSize(1000)
|
||||
->exporter(PlayerHistoryExporter::class)
|
||||
->label('Download')
|
||||
->fileName(fn (Export $export): string => 'player-history-'.date('d.m.Y-H.i')."-{$export->getKey()}")
|
||||
->icon('phosphor-download'),
|
||||
->icon('phosphor-download')
|
||||
->columnMapping(false)
|
||||
->chunkSize(500)
|
||||
->exporter(StatistikoPlayerExporter::class)
|
||||
->fileName(function (Export $export): string {
|
||||
$options = $export->getOptions();
|
||||
switch ($options['limit']) {
|
||||
case 1:
|
||||
return 'player-history-0-200k-'.date('d.m.Y-H.i');
|
||||
case 2:
|
||||
return 'player-history-200k-400k-'.date('d.m.Y-H.i');
|
||||
case 3:
|
||||
return 'player-history-400k-600k-'.date('d.m.Y-H.i');
|
||||
case 4:
|
||||
return 'player-history-600k-800k-'.date('d.m.Y-H.i');
|
||||
case 5:
|
||||
return 'player-history-800k-1000k-'.date('d.m.Y-H.i');
|
||||
default:
|
||||
return 'generic';
|
||||
}
|
||||
})
|
||||
->modifyQueryUsing(function (Builder $query, array $options) {
|
||||
if (isset($options['limit'])) {
|
||||
switch ($options['limit']) {
|
||||
case 1:
|
||||
return $query->skip(0)->take(200000);
|
||||
case 2:
|
||||
return $query->skip(200000)->take(200000);
|
||||
case 3:
|
||||
return $query->skip(400000)->take(200000);
|
||||
case 4:
|
||||
return $query->skip(600000)->take(200000);
|
||||
case 5:
|
||||
return $query->skip(800000)->take(200000);
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}),
|
||||
Action::make('count')
|
||||
->color('gray')
|
||||
->tooltip('Count values from selected column')
|
||||
|
||||
Reference in new issue
Block a user