Closed arkniazi closed 2 years ago
This is due to how factories were changed into classes in Laravel 8. You either need to remove the factory reference from your service providers or install Laralvel's legacy factory package to support old style factories.
composer require laravel/legacy-factories
Yes I have removed that code. Because right now I don't have any factories in the module. And also I'm moving all the factories classes to newer version.
But if I add the factories using newer version in Modules. Will they automatically loaded? Now that I have removed the reference.
yes, they are loaded by their namespaces so you only need to reference the factories from the models
For example:
class Contact extends Model
{
use HasFactory;
protected $fillable = ['name', 'email'];
protected static function newFactory()
{
return ContactFactory::new();
}
}
I cover using Factories with modules in my Laravel Modules book https://dcblogdev.gumroad.com/l/laravel-the-modular-way
Thanks a lot @dcblogdev for the details response.
Getting error after upgrading laravel framework from 7 to 8.
Illuminate\Contracts\Container\BindingResolutionException
Target class [Illuminate\Database\Eloquent\Factory] does not exist.
Error is in ServiceProvider of the module. It can't locate factory call.