当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::with方法代码示例

本文整理汇总了PHP中app\models\Article::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::with方法的具体用法?PHP Article::with怎么用?PHP Article::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Article的用法示例。


在下文中一共展示了Article::with方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit

 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]);
 }
开发者ID:Thor89,项目名称:horgaszkalandok,代码行数:7,代码来源:ArticleController.php

示例2: edit

 /**
  * 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"));
 }
开发者ID:bassx1,项目名称:lessons,代码行数:14,代码来源:ArticlesController.php

示例3: index

 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());
 }
开发者ID:popohum,项目名称:Earths-Best,代码行数:8,代码来源:ArticleController.php

示例4: index

 /**
  * 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);
 }
开发者ID:xinzou,项目名称:blog,代码行数:14,代码来源:ArticleController.php

示例5: index

 /**
  * 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'));
 }
开发者ID:nutsdo,项目名称:nong-store,代码行数:14,代码来源:HomeController.php

示例6: index

 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());
 }
开发者ID:popohum,项目名称:Earths-Best,代码行数:10,代码来源:UserController.php

示例7: getNewArticleList

 /**
  * 获取最新文章列表
  * @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;
 }
开发者ID:xinzou,项目名称:blog,代码行数:14,代码来源:Article.php

示例8: cate

 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());
 }
开发者ID:popohum,项目名称:Earths-Best,代码行数:20,代码来源:HomeController.php

示例9: show

 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'));
 }
开发者ID:nutsdo,项目名称:nong-store,代码行数:21,代码来源:ArticleController.php

示例10: index

 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());
 }
开发者ID:Thor89,项目名称:horgaszkalandok,代码行数:21,代码来源:PostController.php

示例11: comments

 public function comments($article_id)
 {
     $article = Article::with('comments')->find($article_id);
     return view('dashboard.article.comments', compact('article'));
 }
开发者ID:nutsdo,项目名称:nong-store,代码行数:5,代码来源:ArticleController.php

示例12: blog

 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]);
 }
开发者ID:Thor89,项目名称:horgaszkalandok,代码行数:16,代码来源:HomeController.php


注:本文中的app\models\Article::with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。