towhid
8 months ago

how to work my created sedder class with my factory class

Posted 8 months ago by towhid

i created ProductSeeder and ProductFactory File

ProductSeeder

use Illuminate\Database\Seeder;
use App\Product;

class ProductSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        // $this->call(Product::class);
        factory(Product::class,20)->create();
    }
}

ProductFactory

use Faker\Generator as Faker;
use App\Product;

$factory->define(Product::class, function (Faker $faker) {
    return [
        'productName' => $faker->word,
        'categoryId' => 2,
        'price' =>$faker-> numberBetween($min = 50, $max = 10000),
        'qty' =>$faker-> numberBetween($min = 10, $max = 100),
        'shortDescription' => $faker->text,
        'longDescription' => $faker->text,
        'pic' => 'productImage/fb.jpg',
        'publicationStatus' => 1,
    ];
});

and use command this line

php artisan db:seed

its not work --- and not error show also

thank you

Please sign in or create an account to participate in this conversation.