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] Tweak factory generator #34947

Merged
merged 1 commit into from
Oct 23, 2020

Conversation

MatusBoa
Copy link
Contributor

@MatusBoa MatusBoa commented Oct 23, 2020

Hello,

first of all I would like to say this is my first PR targeting large application(framework) like Laravel.

I recently switched to Laravel 8.0 and found that, when generating factory, first argument (factory name) is ignored (only used to generate file name). This PR fixes this behavior so, class name is same as file name. I am not sure if current behavior is intentional, but I found that factory class name does not necessary match model name in my case. Did not find any tests for factory generation. Please, feel free to leave any feedback!

Current behavior

My models

  • Parameter\Parameter
  • Parameter\Layout

$ php artisan make:factory ParameterLayoutFactory

Creates (Model ParameterLayout not found)

class ModelFactory extends Factory

Expected behavior

$ php artisan make:factory ParameterLayoutFactory

Creates (class name inherited from name argument)

class ParameterLayoutFactory extends Factory

Thanks.

@StefanoDucciConvenia
Copy link
Contributor

Hey, you forgot to add [8.x] at the beginning of your title. I liked your PR, make sense, It's rare creates a Factory without Model option but it will help in cases where you forgot to create with the Model.

@MatusBoa MatusBoa changed the title Tweak factory generator [8.x] Tweak factory generator Oct 23, 2020
@taylorotwell
Copy link
Member

This will break other cases.

@MatusBoa
Copy link
Contributor Author

Maybe, if model option is provided, it will have same behavior as current? @taylorotwell

@taylorotwell
Copy link
Member

What is the full path namespace to your models. They are really just Parameter\Parameter? No App?

@MatusBoa
Copy link
Contributor Author

MatusBoa commented Oct 23, 2020

What is the full path namespace to your models. They are really just Parameter\Parameter? No App?

Full namespace is App\Database\Parameter\Parameter and App\Database\Parameter\Layout

@taylorotwell taylorotwell merged commit 54d5ddc into laravel:8.x Oct 23, 2020
@taylorotwell
Copy link
Member

I think you are right and this change is OK. Thanks.

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.

None yet

3 participants