I'm trying to change my factories directory to a custom path, so I'm using this as I saw in a laracasts thread:
use Illuminate\Database\Eloquent\Factory as Factory;
class FactoryServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton(Factory::class, function () {
return Factory::construct(new Faker\Generator, app_path() .'/Core/Database/Factories');
});
}
}
The new path works, my factory files inside the new directory are loaded. But now when I try to use the factory from seeders on php artisan migrate:refresh --seed
I'm getting
[InvalidArgumentException] Unknown formatter "name"
from the $faker instance inside the factory definition:
$factory->define(User::class, function (Faker\Generator $faker) {
return[
'name' => $faker->name,
'email' => $faker->freeEmail,
'password' => bcrypt($faker->word),
'remember_token' => str_random(10)
];
});
This error appears with all the formatters, not just with name.
Where is the problem? The factory works fine before I change the path.