MySQL: JSON-Schlüsselreihenfolge darf keine Rolle spielen
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m40s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m23s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m53s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m47s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m2s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m5s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 2m50s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 2m41s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m6s
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m40s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m23s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m53s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m47s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m2s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m5s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 2m50s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 2m41s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m6s
MySQL speichert Schlüssel in JSON-Spalten sortiert, MariaDB unverändert. - Seiten: „Stand unverändert → kein Entwurf“ vergleicht jetzt unabhängig von der Schlüsselreihenfolge (auf MySQL entstand sonst bei jedem Speichern ein Entwurf) - Formulare: Antworten in Ergebnisansicht und E-Mail in der Reihenfolge des Formulars - Tests vergleichen assoziative Arrays ohne Reihenfolge; neue Tests dafür Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
21c706e5f5
commit
2b5fe55f8e
9 changed files with 92 additions and 6 deletions
|
|
@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Inhaus\Plugins\Forms\FormFields;
|
||||
|
||||
/**
|
||||
* Ein ausgefülltes Formular. „data“ enthält je Feld Bezeichnung, Typ und Wert –
|
||||
|
|
@ -50,6 +51,20 @@ class FormSubmission extends Model
|
|||
return $this->hasMany(FormFile::class, 'submission_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Antworten in der Reihenfolge des Formulars; Felder, die es nur noch in
|
||||
* dieser Einsendung gibt, am Ende. (MySQL speichert JSON-Schlüssel sortiert.)
|
||||
*
|
||||
* @return array<string, array{label: string, type: string, value: mixed}>
|
||||
*/
|
||||
public function orderedAnswers(): array
|
||||
{
|
||||
$data = (array) $this->data;
|
||||
$order = array_keys(FormFields::inputs($this->form));
|
||||
|
||||
return array_replace(array_intersect_key(array_flip($order), $data), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wert als Text (Listen mit Komma, Ja/Nein, Dateinamen).
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue