public function saveData($searchString) { // get IP and actual Date $ip = $this->request->getRemoteAddress(); // get datetime $date = new \DateTime(); // new gneral entity $search = new Search(); $search->setSearch($searchString); $search->setDate($date); $search->setIp($ip); $this->em->persist($search); return $search; }