Пример #1
0
 /**
  * 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
0
 /**
  * Run the database seeds.
  *
  * @return  void
  */
 public function run()
 {
     Tag::truncate();
     User::truncate();
     Bookmark::truncate();
     DB::table('bookmark_tag')->truncate();
     // Start with 10 users, then iterate through each one to populate the other tables
     $users = factory(App\User::class, 50)->create();
     $users->each(function ($user) {
         // Create a variable number of bookmarks/tags and persist them to the DB.
         // saveMany() automatically associates them with the current user_id.
         $bookmarks = factory(App\Bookmark::class, rand(2, 5))->make();
         $user->bookmarks()->saveMany($bookmarks);
         $tags = factory(App\Tag::class, rand(2, 5))->make();
         $user->tags()->saveMany($tags);
         // Everything is populated now except the bookmark_tag pivot table.
         // For that we need another loop.
         $tags->each(function ($tag) use($bookmarks) {
             for ($i = 0; $i < rand(1, 3); $i++) {
                 // Select a random bookmark from the $bookmarks collection,
                 // then attach the tag only IF the tag has not already been attached
                 // to that bookmark.
                 $bookmark = $bookmarks[rand(0, $bookmarks->count() - 1)];
                 if (!$bookmark->tags()->where('tag_id', $tag->id)->exists()) {
                     $bookmark->tags()->attach($tag);
                 }
             }
         });
     });
 }
Пример #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // truncate():
     // If you wish to truncate the entire table,
     // which will remove all rows and reset the auto-incrementing ID to zero,
     // you may use the truncate method.
     Tag::truncate();
     factory(Tag::class, 5)->create();
 }
Пример #4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('set foreign_key_checks = 0');
     DB::table('article_tag')->truncate();
     Tag::truncate();
     DB::statement('set foreign_key_checks = 1');
     Tag::create(['id' => 1, 'name' => 'personal']);
     Tag::create(['id' => 2, 'name' => 'work']);
     Tag::create(['id' => 3, 'name' => 'coding']);
     Tag::create(['id' => 4, 'name' => 'food']);
     Model::reguard();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Tag::truncate();
     factory(Tag::class, 5)->create();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Tag::truncate();
     factory('App\\Tag', 10)->create();
 }
Пример #7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \App\Tag::truncate();
     factory(App\Tag::class, 10)->create();
     //
 }