'json', 'status' => InvoiceStatus::class, 'via' => BillKind::class, ]; /** @var array */ public $dates = [ 'sent_at', ]; /** * @return HasMany */ public function positions(): HasMany { return $this->hasMany(InvoicePosition::class); } public static function createForMember(Member $member): self { return static::create([ 'to' => [ 'name' => 'Familie ' . $member->lastname, 'address' => $member->address, 'zip' => $member->zip, 'location' => $member->location, ], 'greeting' => 'Liebe Familie ' . $member->lastname, 'status' => InvoiceStatus::NEW, 'via' => $member->bill_kind, ]); } public static function booted(): void { static::deleting(function ($model) { $model->positions()->delete(); }); } }