Update migration for invoice recipient
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2026-06-23 12:32:32 +02:00
parent ad5bdd07fb
commit 1ef23eb45e
1 changed files with 14 additions and 2 deletions

View File

@ -11,8 +11,20 @@ return new class extends Migration
*/ */
public function up(): void public function up(): void
{ {
if (\DB::table('invoices')->count()) { foreach (DB::table('invoices')->get() as $invoice) {
throw new \Exception('Migration not possibue for current bills.'); $to = json_decode($invoice->to);
$position = DB::table('invoice_positions')->where('invoice_id', $invoice->id)->first();
if ($position) {
$member = DB::table('members')->where('id', $position->member_id)->first();
if ($member) {
$to->email = $member->email_parents ?: $member->email;
}
}
$to->greeting = 'Liebe '.$to->name;
DB::table('invoices')->where('id', $invoice->id)->update(['to' => json_encode($to)]);
} }
Schema::table('invoices', function (Blueprint $table) { Schema::table('invoices', function (Blueprint $table) {