本文整理汇总了PHP中app\Post::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::truncate方法的具体用法?PHP Post::truncate怎么用?PHP Post::truncate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::truncate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//Unguard
Model::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
//Truncate
Participant::truncate();
//Event::truncate();
Tag::truncate();
Post::truncate();
//Image::truncate();
DB::statement('TRUNCATE `taggables`;');
//DB::statement('TRUNCATE `imagables`;');
DB::statement('TRUNCATE `participations`;');
DB::statement('TRUNCATE `albumables`;');
Event::reindex();
Participant::reindex();
User::reindex();
Album::reindex();
//Call
$this->call(ParticipantTableSeeder::class);
$this->call(EventTableSeeder::class);
$this->call(TagTableSeeder::class);
//Reguard
Model::reguard();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
}
示例2: 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();
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Post::truncate();
//limpa a tabela POSt
factory('App\\Post', 15)->create();
//chama a factory e cria 15 registros
}
示例4: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Post::truncate();
foreach (range(1, 10) as $number) {
Post::create(['title' => '(db) post title ' . $number, 'content' => '(db) post content']);
}
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Post::truncate();
$faker = Faker::create('zh_TW');
foreach (range(1, 20) as $id) {
Post::create(['title' => $faker->sentence, 'sub_title' => $faker->sentence, 'content' => $faker->paragraph, 'is_feature' => rand(0, 1), 'page_view' => rand(0, 200), 'created_at' => Carbon::now()->subDays(20 - $id), 'updated_at' => Carbon::now()->subDays(20 - $id)]);
}
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Post::truncate();
$faker = Factory::create('zh_TW');
foreach (range(20, 1) as $number) {
Post::create(['title' => $faker->sentence, 'content' => $faker->paragraph, 'is_feature' => rand(0, 1), 'created_at' => Carbon::now()->subDays($number), 'updated_at' => Carbon::now()->subDays($number)]);
}
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//Pode ser assim \App\Post:: importar e colocar la em cima use App\Post
Post::truncate();
//serve para apagar todos os registros da tabela do db
factory('App\\Post', 3)->create();
//quando rodar o db:seed no artisan cria N post pro blog
}
示例8: run
public function run()
{
$faker = Faker\Factory::create();
Post::truncate();
foreach (range(1, 500) as $index) {
Post::create(['title' => $faker->unique->sentence(1), 'body' => $faker->text(1000)]);
}
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Post::truncate();
Model::unguard();
$this->call(UserTableSeeder::class);
$this->call(PostTableSeeder::class);
Model::reguard();
}
示例10: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Post::truncate();
$faker = Factory::create('zh_TW');
$max_range = 10;
foreach (range($max_range, 1) as $number) {
Post::create(['title' => $faker->title, 'content' => $faker->name, 'is_feature' => rand(0, 1), 'page_view' => rand(0, 1000), 'created_at' => Carbon::now()->subDays($number), 'updated_at' => Carbon::now()->subDays($number)]);
}
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Post::truncate();
//清空資料表資料再重新產生資料
$faker = Factory::create('zh_TW');
foreach (range(10, 1) as $number) {
//range(10,1)搭配Carbon::now()->subDays,把文章時間遞減
Post::create(['title' => $faker->title, 'content' => $faker->paragraph, 'is_feature' => 0, 'page_view' => 0, 'created_at' => Carbon::now()->subDays($number), 'updated_at' => Carbon::now()->subDays($number)]);
}
}
示例12: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
User::truncate();
Post::truncate();
factory('App\\User', 3)->create()->each(function ($user) {
$user->posts()->save(factory('App\\Post')->create());
});
factory('App\\User', 3)->create()->each(function ($user) {
$user->posts()->save(factory('App\\Post', 'post-member')->create());
});
}
示例13: 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');
}
示例14: run
public function run()
{
// Disables foreign key constraints
DB::statement('SET FOREIGN_KEY_CHECKS = 0');
$faker = Faker\Factory::create();
$categories = Category::all()->lists('id');
Post::truncate();
foreach (range(1, 30) as $index) {
$name = $faker->unique()->sentence(6);
Post::create(['category_id' => $faker->randomElement($categories), 'name' => $name, 'slug' => str_slug($name), 'content' => $faker->paragraph(7), 'created_at' => $faker->dateTimeBetween($startDate = '1 years ago', $endDate = '20 days ago')]);
}
// Enables foreign key constraints
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
}
示例15: 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()));
});
}