I have created a Business model using artisan make:model command
, a model factory and a seed method. When running my seed method I get the following error:
InvalidArgumentException Unable to locate factory with name [default] [App\Business].
Can someone tell me what I'm doing wrong?
Business model:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Business extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name'
];
public function resources()
{
return $this->hasMany('App\Resource');
}
}
Business Factory
use Faker\Generator as Faker;
$factory->define(Business::class, function (Faker $faker) {
return [
'name' => $faker->company,
];
});
Seeder Method
$business = factory(App\Business::class, 50)
->create()
->each(function ($u) {
$u->resources()->save(factory(App\Resource::class)->make());
});