Skip to content

Commit

Permalink
Support factories in app directory
Browse files Browse the repository at this point in the history
  • Loading branch information
octoberapp committed Jul 23, 2023
1 parent 82b7b5d commit 28d28f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Database/Factories/HasFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ public static function factory($count = null, $state = [])
*/
protected static function factoryForModel(string $modelName)
{
$factory = str_replace('Models\\', 'Factories\\', $modelName) . 'Factory';
if (strpos($modelName, 'App\\') === 0) {
$factory = str_replace('Models\\', 'Database\\Factories\\', $modelName) . 'Factory';
}
else {
$factory = str_replace('Models\\', 'Updates\\Factories\\', $modelName) . 'Factory';
}

return $factory::new();
}
Expand Down

0 comments on commit 28d28f4

Please sign in to comment.