i just want some dummy data that i can loop out from my data base but when i try to using the seeder i get this error.."unable to locate factory with name [default] [Subject]".. the code i run is php artisan db:seed --class=SubjectSeeder
//this is my ModelFactory.php
$factory->define(App\Subject::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'code' => $faker->str_random(3),
];
});
//this is my SubjectSeeder.php
public function run()
{
$subject = factory(Subject::class)->make();
Product::create([
'name' => $subject->name,
'code' => $subject->code
]);
}
//this is my subject.php
class Subject extends Model
{
protected $fillable = [
'name', 'code',
];
};
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire