/** * Remove post with given id * * @param $id * @return mixed */ public function remove($id) { $post = $this->getRepository()->find($id); EntityManager::remove($post); EntityManager::flush(); return Redirect::route('post.list'); }
/** * POST: Create new object if no id is presented, otherwise update the object with given id * @param Request $request * @return Response */ protected function createOrUpdate(Request $request) { $object = Api::handle($request, $this->getDefaultRepositoryName()); EntityManager::persist($object); EntityManager::flush(); return Api::render($object, $this->getDefaultDetailsSerializerGroup()); }
/** * @param string $prefix * @return array */ protected function _saveTags($prefix = 'testTag#0') { $aTags = [$prefix . '-1', $prefix . '-2', $prefix . '-3']; $savedTags = []; foreach ($aTags as $tagName) { $tagEntity = new Tag($tagName); EntityManager::persist($tagEntity); $savedTags[] = $tagEntity; } EntityManager::flush(); return array_map(function (Tag $oTag) { return $oTag->getId(); }, $savedTags); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $article = EntityManager::find(Article::class, $id); if (!$article) { return view('doctrination.article.show', compact('article')); } EntityManager::remove($article); EntityManager::flush(); return redirect("articles"); }