insert(["InternalPID" => $newInternalPID, "Comment" => $patcom]); } public function updatePatCom(string $patcom, string $InternalPID) { $exists = $this->withDeleted()->where('InternalPID', $InternalPID)->first(); if ($exists) { //Update $this->where('InternalPID', $InternalPID)->set(['EndDate' => null,'Comment' => $patcom])->update(); } else { //Insert $this->insert(['InternalPID' => $InternalPID, 'Comment' => $patcom]); } } public function deletePatCom(string $InternalPID) { $this->where('InternalPID', $InternalPID)->delete(); } }