public function index(Application $app, $page, Request $request) { $articles = new Articles(); $list = $articles->getItems($app, $page); $articles->removeThisItem($app, $request); return $app['twig']->render('articles.twig', array('page' => $request->get('page'), 'articles' => $list)); }
public function getArticle($id) { return Cache::store($this->store)->rememberForever($id, function () use($id) { $article_model = new Articles(); $article = $article_model->published()->getById($id)->with('tags', 'category')->first(); $data = ['id' => $article->id, 'title' => $article->title, 'curl' => $article->curl, 'keywords' => $article->meta_keywords, 'description' => $article->meta_description, 'content' => $article->content, 'created_at' => $article->created_at, 'updated_at' => $article->updated_at, 'is_comments' => $article->comments_enable, 'category' => ['id' => $article->category->id, 'name' => $article->category->name, 'curl' => $article->category->curl]]; foreach ($article->tags as $tag) { $data['tags'][] = ['id' => $tag->id, 'name' => $tag->name, 'curl' => $tag->curl]; } return $data; }); }
public function search(Request $request, Articles $article) { $messages = ['q.required' => 'Введите что-нибудь для приличия!', 'q.max' => 'Слишколм много для поиска!', 'q.min' => 'Слишком мало для поиска!']; //Валидация $this->validate($request, ['q' => 'required|max:50|min:4'], $messages); //Запрос $this->data['query'] = $request->input('q'); //Ответ $this->data['articles'] = $article->search($this->data['query'])->simplePaginate(20); //Добавляем query в путь $this->data['articles']->setPath(route('search', ['q' => $this->data['query']])); return view('search', $this->data); }
public function index(Application $app, Request $form) { $articles = new Articles(); $articles->createForm($app, $form); return $app['twig']->render('article-add.twig', array('form' => $articles->form->createView())); }
/** * ajax 查询文章列表的回复总数 */ public function queryArtilceAllReply() { $articlekey = $_POST['articlekey']; $res = Articles::queryOneAticleReplyCount($articlekey); return $res; }
/** * 查询最新的文章列表 * @return [type] [description] */ public function getnewAtr() { $res = Articles::getNewAtr(); return $res; }