Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Guess the model name when using the make:factory command #34373

Merged
merged 1 commit into from
Sep 18, 2020

Conversation

sileence
Copy link
Contributor

@sileence sileence commented Sep 16, 2020

php artisan make:factory Profession will attempt to find the Profession model in app/ or app/Models.

If the model is found then the previous command will be the equivalent of typing:

php artisan make:factory Profession --model=Profession

If the model is not found in the models directory (either app/Models or app/) then: the default app\Models\Model will be used if the app/Models directory exists, otherwise app\Model will be used.

: $rootNamespace.$model;
return class_exists($rootNamespace.$model)
? $rootNamespace.$model
: $rootNamespace.'Models\\'.$model;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire change doesn't make sense I don't think. For most generator commands it's going to cause unexpected behavior.

@gocanto
Copy link
Contributor

gocanto commented Sep 17, 2020

any reason why you did not go with throwing an exception if models don't exist? - I am trying to work out why having a default arbitrary model would be the way to go here. 😃

@sileence
Copy link
Contributor Author

@gocanto The model could be somewhere else, if it's in a default location then they will get the name autocompleted, if not they can add it manually.

@taylorotwell taylorotwell merged commit 9acf059 into laravel:8.x Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants