Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

[9.x] Rename firstOrNew() to firstOrMake() #2661

Open
caugner opened this issue Jul 7, 2021 · 0 comments
Open

[9.x] Rename firstOrNew() to firstOrMake() #2661

caugner opened this issue Jul 7, 2021 · 0 comments

Comments

@caugner
Copy link

caugner commented Jul 7, 2021

Background

There are four classes that have a firstOrNew() method:

Problem

I noticed that the naming of this method is confusing to junior devs, because it is not consistent with ::make() (which exists both on Builder and HasOneOrMany) and ::create() on the model itself. Therefore it is not obvious what ->firstOrNew() really does.

Solution

I propose to rename firstOrNew() to firstOrMake() to be consistent with the corresponding model methods. Since this is a breaking change, the transition could be made smoother by adding firstOrMake() and deprecating firstOrNew() in 9.x, and only dropping firstOrNew() in 10.x.

PS: Maybe there's an import difference between firstOrNew() and make() that justifies the different naming.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant