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


PHP Post::count方法代码示例

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


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

示例1: showList

 public function showList()
 {
     $count = Post::count();
     $posts = Post::orderBy('created_at', 'DESC')->take(6)->get();
     return view('list', ['count' => $count, 'posts' => $posts]);
     //будет использоваться list.blade.php
 }
开发者ID:Aglok,项目名称:upbrain,代码行数:7,代码来源:BlogController.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($current_page)
 {
     $current_page = $current_page ? $current_page : 1;
     $current_page = $current_page - 1;
     $page = 10;
     //echo $current_page*$page;exit;
     $post = Post::leftJoin('websites', 'posts.website', '=', 'websites.websites_id')->leftJoin('projects', 'posts.project', '=', 'projects.projects_id')->orderby('posts_id', 'desc')->offset($current_page * $page)->limit($page);
     $posts['data'] = $post->get();
     $posts['count'] = Post::count();
     $posts['pageSize'] = $page;
     return response()->json($posts);
 }
开发者ID:QiuCarson,项目名称:doc,代码行数:17,代码来源:PostController.php

示例3: index

 public function index()
 {
     $postsPerPage = $this->_config('posts_on_index');
     // Way 1
     // Define which get method to use to fetch Posts by checking ACL
     // Use that function and the Model's logic to get those posts.
     $unpub = $this->user->hasAccess('blog read unpublished');
     $method = $unpub ? 'newest' : 'newestPublished';
     $posts = models\Post::$method($postsPerPage);
     // The quick 'n dirty //
     $page = Options::one($_GET, 'page', 1, false);
     $start = ($page - 1) * $postsPerPage;
     $conditions = $unpub ? '1' : 'is_published = 1';
     $posts = models\Post::all($conditions . ' ORDER BY created_on DESC LIMIT ' . $start . ', ' . $postsPerPage . '');
     // Don't do it! //
     // Way 2
     // Define the difference in conditions here (instead of in the Model)
     $conditions = $unpub ? '' : array('is_published' => true);
     $numAllPosts = models\Post::count($conditions);
     // Way 3
     // A third way would be a combination like this:
     /*
     			$access = $this->user->hasAccess('blog read unpublished');
     			$posts = model\Post::postsByAccess($access, $this->_config('posts_on_index'));
     */
     // That way you can check access in the Controller and have fetch logic in the Model
     $messages = Session::messages();
     $canCreatePosts = $this->user->hasAccess('blog create posts');
     return get_defined_vars();
     // view will be rendered by row\Controller->_post_action
     return $this->_display(__METHOD__, get_defined_vars(), !$this->AJAX);
     // view will be rendered by Output->display
     return $this->_display(get_defined_vars());
     // view will be rendered by Output->display
 }
开发者ID:rudiedirkx,项目名称:Rudie-on-wheels,代码行数:35,代码来源:blogController.php

示例4: getNumPosts

 public function getNumPosts()
 {
     return \app\models\Post::count(array('author_id' => $this->user_id));
 }
开发者ID:rudiedirkx,项目名称:Rudie-on-wheels,代码行数:4,代码来源:User.php

示例5: numPosts

 public function numPosts()
 {
     return Post::count(array('category_id' => $this->category_id));
 }
开发者ID:rudiedirkx,项目名称:Rudie-on-wheels,代码行数:4,代码来源:Category.php

示例6: index

 /**
  * Dashboard index.
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index()
 {
     $postsCount = Post::count();
     $commentsCount = Comment::whereSeen(0)->count();
     return view('back.index', compact('postsCount', 'commentsCount'));
 }
开发者ID:forehalo,项目名称:materialize-blog,代码行数:11,代码来源:AdminController.php


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