本文整理汇总了PHP中app\Comment::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::truncate方法的具体用法?PHP Comment::truncate怎么用?PHP Comment::truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Comment
的用法示例。
在下文中一共展示了Comment::truncate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
\App\Post::truncate();
\App\Comment::truncate();
factory(\App\Post::class, 10)->create();
factory(\App\Comment::class, 10)->create();
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Comment::truncate();
$faker = Factory::create('zh_TW');
foreach (range(1, 15) as $number) {
Comment::create(['name' => $faker->name, 'email' => $faker->email, 'content' => $faker->paragraph, 'post_id' => rand(1, 10)]);
}
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Comment::truncate();
$faker = Faker::create('zh_TW');
foreach (range(1, 20) as $id) {
Comment::create(['name' => $faker->name, 'email' => $faker->email, 'content' => $faker->paragraph, 'post_id' => rand(1, 20), 'created_at' => Carbon::now()->subDays(20 - $id), 'updated_at' => Carbon::now()->subDays(20 - $id)]);
}
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Disable foreign key checking because truncate() will fail
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
User::truncate();
Post::truncate();
Comment::truncate();
factory(User::class, 10)->create();
factory(Post::class, 50)->create();
factory(Comment::class, 100)->create();
$this->call('OAuthClientSeeder');
// Enable it back
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
/* Probably needs to be updated to NOT truncate User, so contributors pulling down and going through the ReadMe can first create a user, and then seed (allowing the seed to randomly generate posts, comments and subscriptions for the created user first) */
User::truncate();
Post::truncate();
Comment::truncate();
Subbreddit::truncate();
DB::table('subbreddit_user')->truncate();
$users = factory(User::class, 25)->create();
$users->each(function ($user) {
$user->subbreddits()->save(factory(App\Subbreddit::class)->make());
$user->posts()->save(factory(App\Post::class)->make(['subbreddit_id' => rand(1, App\Subbreddit::all()->count())]));
$user->comments()->save(factory(App\Comment::class)->make(['post_id' => rand(1, App\Post::all()->count())]));
$user->comments()->save(factory(App\Comment::class)->make(['comment_id' => rand(1, App\Comment::all()->count())]));
$user->subscribedSubbreddits()->attach(rand(1, App\Subbreddit::all()->count()));
});
}
示例6: run
public function run()
{
// Disables foreign key constraints
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
$faker = Faker\Factory::create();
$posts = DB::table('posts')->get();
Comment::truncate();
foreach (range(1, 50) as $index) {
$post = $faker->randomElement($posts);
Comment::create(['post_id' => $post->id, 'author' => $faker->name(), 'email' => $faker->optional(0.9, '')->email(), 'content' => $faker->sentence(3), 'created_at' => $faker->dateTimeBetween($post->created_at, '1 day ago')]);
}
// All root comments
$parent_comments = Comment::all()->lists('id');
// Generating random lvl of comments
foreach (range(1, 40) as $index) {
$comment = $faker->randomElement(DB::table('comments')->select('id', 'created_at', 'post_id')->get());
Comment::create(['post_id' => $comment->post_id, 'parent_id' => $comment->id, 'author' => $faker->name(), 'email' => $faker->email(), 'content' => $faker->sentence(2), 'created_at' => $faker->dateTimeBetween($comment->created_at, '1 days ago')]);
}
// Enables foreign key constraints
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Comment::truncate();
factory(Comment::class, 30)->create();
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Comment::truncate();
factory('App\\Comment', 30)->create();
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Post::truncate();
Comment::truncate();
factory('App\\Post', 10)->create();
}