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


PHP Article::count方法代码示例

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


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

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     if (Article::count() > 0 && Topic::count() > 0) {
         foreach (range(1, 10) as $index) {
             DB::table('article_topic')->insert(['article_id' => rand(1, Article::count()), 'topic_id' => rand(1, Topic::count())]);
         }
     }
 }
开发者ID:sontdhust,项目名称:eruza,代码行数:13,代码来源:ArticleTopicTableSeeder.php

示例2: index

 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $perPage = 2;
     $article = Article::paginate($perPage);
     $maxPage = intval(ceil(Article::count() / $perPage));
     $firstArticle = $article->shift();
     $others = $article;
     return view('home')->with(['first' => $firstArticle, 'others' => $others, 'maxPage' => $maxPage]);
     /*$categories = Category::all();
       $articles = Article::paginate(15);
       return view('home')->withArticles($articles)->withCategories($categories);*/
 }
开发者ID:Albertao,项目名称:myblog,代码行数:17,代码来源:HomeController.php

示例3: testDeleteOne

 public function testDeleteOne()
 {
     $entities = factory(Article::class, 4)->create()->all();
     $this->addPermalinksToArticles($entities);
     foreach ($entities as $oneEntity) {
         $oneEntity->push();
     }
     $entity = $entities[0];
     $id = $entity->article_id;
     $entityPermalinksCount = $entity->permalinks->count();
     $this->assertEquals($entityPermalinksCount, ArticlePermalink::where('article_id', '=', $id)->count());
     $rowCount = Article::count();
     $permalinksTotalCount = ArticlePermalink::all()->count();
     $this->delete('/articles/' . $id);
     $permalinksTotalCountAfterDelete = ArticlePermalink::all()->count();
     $this->assertResponseStatus(204);
     $this->assertResponseHasNoContent();
     $this->assertEquals($rowCount - 1, Article::count());
     $this->assertEquals($permalinksTotalCount - $entityPermalinksCount, $permalinksTotalCountAfterDelete);
 }
开发者ID:TFidryForks,项目名称:spira,代码行数:20,代码来源:ArticleTest.php

示例4: function

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
use App\Models\Article;
use App\Models\Category;
use App\Models\Comment;
use App\Models\Topic;
use App\Models\User;
$factory->define(User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)];
});
$factory->define(Category::class, function (Faker\Generator $faker) {
    return [];
});
$factory->define(Article::class, function (Faker\Generator $faker) {
    return ['user_id' => rand(1, User::count()), 'category_id' => rand(1, Category::count()), 'title' => $faker->sentence(mt_rand(3, 10)), 'content' => join('<br>', $faker->paragraphs(mt_rand(3, 6))), 'published_at' => rand(0, 2) >= 1 ? Carbon\Carbon::now() : null];
});
$factory->define(Topic::class, function (Faker\Generator $faker) {
    return [];
});
$factory->define(Comment::class, function (Faker\Generator $faker) {
    return ['user_id' => rand(1, User::count()), 'article_id' => rand(1, Article::count()), 'content' => join("\n", $faker->paragraphs(mt_rand(1, 2)))];
});
开发者ID:sontdhust,项目名称:eruza,代码行数:30,代码来源:ModelFactory.php


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