Update migration for invoice recipient
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
ad5bdd07fb
commit
1ef23eb45e
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue