@@ -80,7 +80,7 @@ public function handle()
8080 $ filename = 'database/factories/ ' . class_basename ($ model ) . 'Factory.php ' ;
8181
8282 if ($ this ->files ->exists ($ filename ) && !$ this ->force ) {
83- $ this ->warn ( ' Model factory exists, use --force to overwrite: ' . $ filename );
83+ $ this ->line ( ' <fg=yellow> Model factory exists, use --force to overwrite:</fg=yellow> ' . $ filename );
8484
8585 continue ;
8686 }
@@ -93,9 +93,9 @@ public function handle()
9393
9494 $ written = $ this ->files ->put ($ filename , $ result );
9595 if ($ written !== false ) {
96- $ this ->info ( ' Model factory created: ' . $ filename );
96+ $ this ->line ( ' <info> Model factory created:</info> ' . $ filename );
9797 } else {
98- $ this ->error ( ' Failed to create model factory: ' . $ filename );
98+ $ this ->line ( ' <error> Failed to create model factory:</error> ' . $ filename );
9999 }
100100 }
101101 }
@@ -280,7 +280,9 @@ protected function getPropertiesFromMethods($model)
280280 $ property = method_exists ($ relationObj , 'getForeignKeyName ' )
281281 ? $ relationObj ->getForeignKeyName ()
282282 : $ relationObj ->getForeignKey ();
283- $ this ->setProperty ($ property , 'factory( ' . get_class ($ relationObj ->getRelated ()) . '::class)->create()-> ' . $ relatedObj ->getKeyName ());
283+ $ this ->setProperty ($ property , 'function () {
284+ return factory( ' . get_class ($ relationObj ->getRelated ()) . '::class)->create()-> ' . $ relatedObj ->getKeyName () . ';
285+ } ' );
284286 }
285287 }
286288 }
@@ -294,7 +296,7 @@ protected function getPropertiesFromMethods($model)
294296 */
295297 protected function setProperty ($ name , $ type = null )
296298 {
297- if ($ type !== null && Str::startsWith ($ type , 'factory ( ' )) {
299+ if ($ type !== null && Str::startsWith ($ type , 'function ( ' )) {
298300 $ this ->properties [$ name ] = $ type ;
299301
300302 return ;
0 commit comments