/** * Run the database seeds. * * @return void */ public function run() { Category::truncate(); $categories = [['name' => 'Programming'], ['name' => 'Foreign Language'], ['name' => 'Discover'], ['name' => 'News'], ['name' => 'Relax']]; foreach ($categories as $category) { factory(Category::class)->create($category); } }
public function run() { Category::truncate(); factory(Category::class, 'asset-category', 10)->create(); factory(Category::class, 'accessory-category', 5)->create(); factory(Category::class, 'consumable-category', 5)->create(); factory(Category::class, 'component-category', 5)->create(); }
/** * Run the database seeds. * * @return void */ public function run() { Category::truncate(); $categoryNames = ['coding', 'social', 'faith', 'health', 'minimalism']; foreach ($categoryNames as $name) { $category = new Category(['name' => $name]); $category->user()->associate(User::first()); $category->save(); } }