This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

pratyushpundir6424
pratyushpundir6424

Has anyone used Laravel's Model Factories in October yet? If yes, I'd really appreciate a point in the right direction. Where should I be defining the factories?

mberizzo
mberizzo

Could you solve it? I have the same problem

pratyushpundir6424
pratyushpundir6424

No, I couldn't. I resorted to using normal seeds. I'm sure there is a way to make this work I just don't know it yet. The side-effect, however, is that it seems to cause weird issues with testing. See the develop branch here -> https://github.com/pratyushpundir/oc-sublimeChimp.

Then again, it's gotta do something with the way my tests are written.

pratyushpundir6424
pratyushpundir6424

Just noticed, tests only seem to fail on PHP 5 versions. The weird thing is that tests on PHP 7.0 and PHP 7.1 run fine on (while they fail on PHP 5) Travis but error out on both PHP 5 and 7 version on my local environment.

vdomah
vdomah

Any news on factories usage in october?

Elidrake
Elidrake

I know it's been years, but I'm currently in the process of migrating a Laravel project into October, and needed access to factories for bringing over my test suite. Here's the solution I came up with: https://stackoverflow.com/questions/57927161/how-can-i-use-model-factories-in-october-cms/57927162#57927162

alexwenzel
alexwenzel

Elidrake said:

I know it's been years, but I'm currently in the process of migrating a Laravel project into October, and needed access to factories for bringing over my test suite. Here's the solution I came up with: https://stackoverflow.com/questions/57927161/how-can-i-use-model-factories-in-october-cms/57927162#57927162

Thank you !

vdomah
vdomah

Here is also a snippet to add your factories in the plugin: https://octoberduck.com/ru/article/factories-in-a-plugin

Place this code in your Plugin.php:

use Illuminate\Database\Eloquent\Factory as EloquentFactory;

public function register()
{
    app(EloquentFactory::class)->load(plugins_path('author/plugin/factories'));
}

1-8 of 8

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.