public function removeFecFiling(FecFiling $filing) { if ($filing->relationship_id != $this->relationship_id) { throw new Exception("Can't remove FecFiling that doesn't belong to this Donation"); } $relationship = $this->Relationship; if ($relationship->amount == $this->getFecFilingAmountSum()) { $relationship->amount -= $filing->amount; } $relationship->filings = $this->countFecFilings() - 1; $relationship->save(); $filing->delete(); }