/** * Find posts * * @param Request $request * @return mixed */ public function search(Request $request) { $searchStr = $request->get('q'); $posts = $this->postService->search($searchStr); if ($request->has('ajax')) { return $this->jsonPagination($posts, $this->view('ajax.search', compact('posts'))); } return $this->view('post.search', compact('posts', 'searchStr')); }
/** * List all posts * * @param Request $request * @return \Illuminate\View\View */ public function all(Request $request) { $posts = $this->post->search($request->get('q')); return $this->view('posts.list', compact('posts')); }