0

My seeder Class code is as follows:

    <?php


use App\Category;
use Illuminate\Database\Seeder;





class CategoryTableSeeder extends  Seeder
{
    public function run()
    {

     DB::table('categories')->delete();

     $cats = ['math', 'physics', 'calculus', 'eletronics', 'etc etc'];

            foreach ($cats as $cat)
            {
                Category::create(['category' => $cat]);

            }   


    }
}

When I try to seed it using the following command on CLI:

php artisan db:seed

Nothing happens with no error. What might be wrong with this? I am seeing similar discussion on Github but finding no solution. Your help will be highly appreciated.

Hassan Saqib
  • 2,597
  • 7
  • 28
  • 51

1 Answers1

1

try php artisan db:seed --class=CategoryTableSeeder

If you want to always run this seed add $this->call('CategoryTableSeeder'); in the DatabaseSeeder

Pawel Bieszczad
  • 12,925
  • 3
  • 37
  • 40