Set permanent bank account of member
This commit is contained in:
parent
858ae7f8d1
commit
b541d246e0
app
|
@ -61,7 +61,7 @@ class InsertMemberAction
|
|||
}
|
||||
|
||||
return tap(Member::updateOrCreate(['nami_id' => $member->id], $payload), function ($insertedMember) use ($member) {
|
||||
$insertedMember->bankAccount()->updateOrCreate([
|
||||
$insertedMember->bankAccount->update([
|
||||
'iban' => $member->bankAccount->iban,
|
||||
'bic' => $member->bankAccount->bic,
|
||||
'blz' => $member->bankAccount->blz,
|
||||
|
|
|
@ -12,4 +12,6 @@ class BankAccount extends Model
|
|||
use HasFactory;
|
||||
|
||||
public $guarded = [];
|
||||
|
||||
public $primaryKey = 'member_id';
|
||||
}
|
||||
|
|
|
@ -304,12 +304,17 @@ class Member extends Model implements Geolocatable
|
|||
|
||||
public static function booted()
|
||||
{
|
||||
static::created(function (self $model): void {
|
||||
$model->bankAccount()->create([]);
|
||||
});
|
||||
|
||||
static::deleting(function (self $model): void {
|
||||
$model->memberships->each->delete();
|
||||
$model->courses->each->delete();
|
||||
$model->invoicePositions->each(function ($position) {
|
||||
$position->delete();
|
||||
});
|
||||
$model->bankAccount()->delete();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue