/** * Remove the specified resource from storage. * * @param $parent_id * @param int $id * @return Response */ public function destroy($id) { if ($this->category->delete($id)) { return redirect()->back()->with('success', 'Category successfully deleted!'); } return redirect()->back()->with('error', 'Error deleting Category !'); }
/** * list of post * * @param array $filter * * @return array */ public function all($filter = []) { if (array_has($filter, "category")) { $category = $this->category->find($filter['category']); $category_ids = $category->getDescendantsAndSelf()->lists('id')->toArray(); $posts = $this->postRepo->getByCategoryId($category_ids, true); } elseif (array_has($filter, "tag")) { $posts = $this->postRepo->getByTags($filter['tag'], true); } elseif (array_has($filter, "query")) { $posts = $this->postRepo->search($filter['query'], true); } else { $posts = $this->postRepo->all($filter); } $postArray = []; foreach ($posts as $post) { $postArray[] = $this->formatPost($post); } $posts = $posts->toArray(); $response = array_except($posts, 'data'); $response['data'] = $postArray; return $response; }
/** * gets deleted posts,question,answers * @param array $filter * @return array|bool */ public function deleted($filter = []) { try { if (isset($filter['last_updated'])) { $filter['deleted_at'] = \Carbon::createFromTimestamp($filter['last_updated'])->toDateTimeString(); } $data['posts'] = $this->post->deleted($filter); $data['categories'] = $this->category->deleted($filter); return $data; } catch (\Exception $e) { $this->logger->error($e); return false; } return false; }