ref_model = \get_class($object); $this->ref_model_id = $object->id; $this->save(); return $this; } /** * Return an instance of the object or null * @return \App\Interfaces\Model|null */ public function getReferencedObject() { if ($classname = $this->ref_model) { $klass = new $this->ref_model; return $klass->find($this->ref_model_id); } return null; } }