public function edit($title)
 {
     $this->middleware('auth');
     $article_seo_url = addslashes(strip_tags($title));
     $article = Article::with('author', 'articleImages')->where('seo_url', $article_seo_url)->first();
     return view('article.edit', ['article' => $article]);
 }
Example #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $tags = Tag::lists("name", "id");
     $article = Article::with("tags")->find($id);
     $categories = Category::lists("name", "id");
     //        dd($article->tags->lists("id"));
     return view("dashboard.articles.edit", compact("article", "categories", "tags"));
 }
 public function index()
 {
     $articles = Article::with('comment')->select(['id', 'title', 'tag', 'view', 'introduction', 'updated_at', 'created_at'])->whereNull('deleted_at')->paginate(1);
     foreach ($articles as $v) {
         $v->last_reply = $v->comment->max('created_at');
     }
     return view('user.article.index')->with('articles', $articles)->with('tops', ArticleController::getTop10());
 }
Example #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if ($result = check_auth_to('WZGL_INDEX')) {
         return $result;
     }
     $site = Config::get('site');
     $data['articleList'] = Article::with('articleUser')->paginate($site['page_size']);
     return view('admin.article.index', $data);
 }
Example #5
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //banner
     $banners = Banner::orderBy('created_at', 'DESC')->take(7)->get();
     //最新
     $last_articles = Article::with('author')->orderBy('created_time', 'DESC')->take(12)->get();
     $hot_articles = Article::orderBy('views', 'DESC')->take(10)->get();
     return view('home', compact('banners', 'last_articles', 'hot_articles'));
 }
Example #6
0
 public function index()
 {
     $user_id = \Auth::user()->id;
     $articles = Article::with('comment')->select(['id', 'title', 'tag', 'view', 'introduction', 'updated_at', 'created_at'])->where('user_id', $user_id)->where('status', config('DbStatus.article.status'))->paginate(1);
     foreach ($articles as $v) {
         $v->tag = str_replace(',', ',', $v->tag);
         $v->last_reply = $v->comment->max('created_at');
     }
     return view('user.user')->with('articles', $articles)->with('tops', ArticleController::getTop10());
 }
Example #7
0
 /**
  * 获取最新文章列表
  * @return array
  */
 public static function getNewArticleList()
 {
     $page = Input::get('page', 1);
     if (empty($articles = Cache::tags(self::REIDS_NEW_ARTICLE_CACHE)->get(self::REIDS_NEW_ARTICLE_CACHE . $page))) {
         $articles = Article::with('articleUser')->orderBy('id', 'desc')->paginate(config('site')['article_list_count']);
         //文章列表(最新)
         Cache::tags(self::REIDS_NEW_ARTICLE_CACHE)->put(self::REIDS_NEW_ARTICLE_CACHE . $page, $articles, config('site')['redis_cache_time']);
     }
     return $articles;
 }
Example #8
0
 public function cate($cate = null)
 {
     $cateId = DB::table('article_categories')->select('id')->where('title', $cate)->first();
     if (is_null($cateId)) {
         return $this->tagList();
     }
     if ($cate != null) {
         $articles = Article::with('comment')->select(['id', 'title', 'tag', 'view', 'introduction', 'updated_at', 'created_at'])->whereNull('deleted_at')->where('category_id', $cateId->id)->paginate(10);
     } else {
         return $this->tagList();
     }
     $list = array();
     foreach ($articles as $v) {
         $v->tag = str_replace(',', ',', $v->tag);
         $list = array_merge($list, explode(',', $v->tag));
         $v->last_reply = $v->comment->max('created_at');
     }
     $tags = array_unique($list);
     return view('home.cateList')->with('articles', $articles)->with('tags', $tags)->with('tops', ArticleController::getTop10());
 }
Example #9
0
 public function show($id)
 {
     Article::where('id', $id)->increment('views');
     //阅读量加1
     $article = Article::with(['comments' => function ($query) {
         $query->take(10);
     }])->find($id);
     //        dd($article);
     $views = Article::where('author_id', $article->author_id)->where('author_type', $article->author_type)->sum('views');
     $comments_count = Comment::where('article_id', $id)->count();
     $hots = Article::orderBy('views', 'desc')->take(10)->get();
     $is_like = false;
     $is_collection = false;
     $is_follow = false;
     if ($this->login_user) {
         $is_like = Like::where('user_id', $this->login_user->id)->where('like_type', 'article')->where('like_id', $id)->first();
         $is_collection = Collection::where('user_id', $this->login_user->id)->where('collection_type', 'article')->where('collection_id', $id)->first();
         $is_follow = DB::table('user_follow')->where('user_id', $this->login_user->id)->where('follow_id', $article->author_id)->first();
     }
     return view('front.article.index', compact('article', 'views', 'comments_count', 'hots', 'is_like', 'is_collection', 'is_follow'));
 }
Example #10
0
 public function index()
 {
     $articles = Article::with(['articleImages', 'type', 'author'])->orderBy('created_at', 'DESC')->paginate(30);
     if (Request::isMethod('get')) {
         $whereConditions = [];
         if (!empty(Input::all())) {
             foreach (Input::all() as $key => $input) {
                 if (!empty($input) && $key != 'page' && $key != '_token') {
                     $whereConditions[$key] = $input;
                 }
             }
             $articles = Article::with(['articleImages', 'type', 'author'])->where($whereConditions)->paginate(30);
         } else {
             $articles = Article::with(['articleImages', 'type', 'author'])->orderBy('created_at', 'DESC')->paginate(30);
         }
     } else {
         $articles = Article::with(['articleImages', 'type', 'author'])->orderBy('created_at', 'DESC')->paginate(30);
     }
     Request::flash();
     return view('admin.post.index')->with(['articles' => $articles])->withInput(Input::all());
 }
Example #11
0
 public function comments($article_id)
 {
     $article = Article::with('comments')->find($article_id);
     return view('dashboard.article.comments', compact('article'));
 }
Example #12
0
 public function blog($title)
 {
     $selectedPostType = addslashes($title);
     $postCategoryName = ArticleTypes::where(['seo_url' => $selectedPostType])->first();
     if (!$postCategoryName) {
         return redirect('/');
     }
     $articles = Article::with('type')->whereHas('type', function ($query) use($selectedPostType) {
         $query->where(['seo_url' => $selectedPostType]);
     })->with('author')->paginate(5);
     $popular = Article::with('type')->whereHas('type', function ($query) use($selectedPostType) {
         $query->where(['seo_url' => $selectedPostType]);
     })->with('author')->orderBy('viewed')->take(5)->get()->toArray();
     //$popular  = Article::with(['author','type'])->where(['seo_url' => $title])->orderBy('viewed')->take(5)->get()->toArray();
     return view('blog.bloghome', ['articles' => $articles, 'popular' => $popular, 'postCategoryName' => $postCategoryName]);
 }