本文整理汇总了PHP中app\Post::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::count方法的具体用法?PHP Post::count怎么用?PHP Post::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::count方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display the dashboard once the user is logged
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$nb_users = User::count();
$nb_posts = Post::count();
$nb_pages = Page::count();
return view('admin.admin', compact('nb_users', 'nb_posts', 'nb_pages'));
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$users_count = User::count();
$posts_count = Post::count();
$galleries_count = Gallery::count();
return response()->json(['users_count' => $users_count, 'posts_count' => $posts_count, 'galleries_count' => $galleries_count]);
}
示例3: boardStats
/**
* Returns the information specified by boardStats
*
* @return array (indexes and vales based on $boardStats)
*/
protected function boardStats()
{
$controller =& $this;
$stats = Cache::remember('index.boardstats', 60, function () use($controller) {
$stats = [];
foreach ($controller->boardStats as $boardStat) {
switch ($boardStat) {
case "boardCount":
$stats[$boardStat] = Board::whereIndexed()->count();
break;
case "boardIndexedCount":
$stats[$boardStat] = Board::count();
break;
case "postCount":
$stats[$boardStat] = Post::count();
break;
case "postRecentCount":
$stats[$boardStat] = Post::recent()->count();
break;
}
}
return $stats;
});
return $stats;
}
示例4: testNumberOfPostsIsEqualOrHigherAfterUpdate
/**
* Assert that the numbers of posts doens't decline after running update command
*
* @return void
*/
public function testNumberOfPostsIsEqualOrHigherAfterUpdate()
{
$totalPosts = Post::count();
$totalDificultyLevels = PostDificulty::count();
Artisan::call('update', ['--migrationRefresh' => 'default']);
$this->assertTrue($totalDificultyLevels <= PostDificulty::count());
$this->assertTrue($totalPosts <= Post::count());
}
示例5: index
public function index()
{
$totallikes = Like::count();
$totalposts = Post::count();
$posts = Post::with('cat', 'likes')->paginate(config('app.posts_per_page'));
$page = $posts->currentPage();
$lastpage = $posts->lastPage();
return view('index', compact('totallikes', 'totalposts', 'posts', 'page', 'lastpage', 'title'));
}
示例6: index
public function index()
{
$pages = \App\Page::count();
$banners = \App\Banner::count();
$coupons = \App\Coupons::count();
$posts = \App\Post::count();
$users = \App\User::count();
$images = \App\Image::count();
return view('home')->with('pages', $pages)->with('banners', $banners)->with('coupons', $coupons)->with('posts', $posts)->with('users', $users)->with('images', $images);
}
示例7: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$posts_published = Post::published()->count();
$posts_editing = Post::where('published', 'uc')->count();
$posts_sticky = Post::where('is_sticky', 'on')->count();
$posts = Post::count();
$users = User::count();
$jobs = Job::count();
$questions = Question::count();
$categories = Category::count();
return view('admin.stats.index', compact('posts', 'posts_published', 'posts_sticky', 'posts_editing', 'users', 'jobs', 'questions', 'categories'));
}
示例8: testSaveWithRelations
public function testSaveWithRelations()
{
// one-to-many, many-to-many
$item = factory(App\Post::class)->make();
$post = $item->toArray();
$post['comments'] = [];
$post['comments'][] = factory(App\Comment::class)->make()->toArray();
$post['tags'] = [];
foreach (App\Tag::all() as $t) {
$post['tags'][] = $t['id'];
}
$item->saveWithRelations($post);
$item = App\Post::find(4);
self::assertInstanceOf('App\\Post', $item);
self::assertEquals('4', $item['id']);
$tags = $item->tags;
self::assertCount(3, $tags);
$comments = $item->comments;
self::assertCount(1, $comments);
// one-to-one
$item = factory(App\Comment::class)->make();
$comment = $item->toArray();
$comment['post'] = factory(App\Post::class)->make()->toArray();
$item->saveWithRelations($comment);
$item = App\Comment::find(11);
self::assertEquals('11', $item['id']);
self::assertEquals(11, App\Comment::count());
$post = $item->post;
self::assertEquals('5', $post['id']);
self::assertEquals(5, App\Post::count());
// db rollback
$this->rollback();
}