Last active
October 11, 2019 17:10
-
-
Save james2doyle/0983364225874658e5f8144d67870798 to your computer and use it in GitHub Desktop.
Load model factories from a different folder in Laravel. Useful for tests that use vendor factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// load factories from a different folder - useful for legacy vendor packages | |
$this->app->singleton(\Illuminate\Database\Eloquent\Factory::class, function ($app) { | |
$faker = $app->make(\Faker\Generator::class); | |
return \Illuminate\Database\Eloquent\Factory::construct($faker, base_path('tests/database/factories')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment