*/ public function member(): BelongsTo { return $this->belongsTo(Member::class); } /** * @return BelongsTo */ public function invoice(): BelongsTo { return $this->belongsTo(Invoice::class); } public static function booted(): void { static::saved(function ($model) { $model->member->touch(); }); static::deleted(function ($model) { if ($model->invoice->positions()->get()->count() === 0) { $model->invoice->delete(); } $model->member->touch(); }); } }