mirror of
https://github.com/anna-sara/vbytes_lan.git
synced 2025-12-24 13:27:12 +01:00
Participant export
This commit is contained in:
parent
0d5601505b
commit
cc960f7d3f
5 changed files with 174 additions and 0 deletions
43
app/Filament/Exports/ParticipantExporter.php
Normal file
43
app/Filament/Exports/ParticipantExporter.php
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Exports;
|
||||||
|
|
||||||
|
use App\Models\Participant;
|
||||||
|
use Filament\Actions\Exports\ExportColumn;
|
||||||
|
use Filament\Actions\Exports\Exporter;
|
||||||
|
use Filament\Actions\Exports\Models\Export;
|
||||||
|
use Illuminate\Support\Number;
|
||||||
|
|
||||||
|
class ParticipantExporter extends Exporter
|
||||||
|
{
|
||||||
|
protected static ?string $model = Participant::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ExportColumn::make('participant_id'),
|
||||||
|
ExportColumn::make('first_name'),
|
||||||
|
ExportColumn::make('surname'),
|
||||||
|
ExportColumn::make('grade'),
|
||||||
|
ExportColumn::make('phone'),
|
||||||
|
ExportColumn::make('email'),
|
||||||
|
ExportColumn::make('guardian_name'),
|
||||||
|
ExportColumn::make('guardian_phone'),
|
||||||
|
ExportColumn::make('guardian_email'),
|
||||||
|
ExportColumn::make('friends'),
|
||||||
|
ExportColumn::make('special_diet'),
|
||||||
|
ExportColumn::make('status')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Export $export): string
|
||||||
|
{
|
||||||
|
$body = 'Your participant export has completed and ' . Number::format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||||
|
|
||||||
|
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||||
|
$body .= ' ' . Number::format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('notifications', function (Blueprint $table) {
|
||||||
|
$table->uuid('id')->primary();
|
||||||
|
$table->string('type');
|
||||||
|
$table->morphs('notifiable');
|
||||||
|
$table->text('data');
|
||||||
|
$table->timestamp('read_at')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('notifications');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('imports', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('completed_at')->nullable();
|
||||||
|
$table->string('file_name');
|
||||||
|
$table->string('file_path');
|
||||||
|
$table->string('importer');
|
||||||
|
$table->unsignedInteger('processed_rows')->default(0);
|
||||||
|
$table->unsignedInteger('total_rows');
|
||||||
|
$table->unsignedInteger('successful_rows')->default(0);
|
||||||
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('imports');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('exports', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('completed_at')->nullable();
|
||||||
|
$table->string('file_disk');
|
||||||
|
$table->string('file_name')->nullable();
|
||||||
|
$table->string('exporter');
|
||||||
|
$table->unsignedInteger('processed_rows')->default(0);
|
||||||
|
$table->unsignedInteger('total_rows');
|
||||||
|
$table->unsignedInteger('successful_rows')->default(0);
|
||||||
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('exports');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('failed_import_rows', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->json('data');
|
||||||
|
$table->foreignId('import_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->text('validation_error')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('failed_import_rows');
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue