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

Could Model::fresh and Model::with have same signature? #13933

Closed
torkiljohnsen opened this issue Jun 10, 2016 · 0 comments
Closed

Could Model::fresh and Model::with have same signature? #13933

torkiljohnsen opened this issue Jun 10, 2016 · 0 comments

Comments

@torkiljohnsen
Copy link

torkiljohnsen commented Jun 10, 2016

Right now, fresh and with both accept array or string, fresh basically creates a new object using with, passing along the $with parameter.

But this returns radically different results:

$model1 = new SomeModel::with('relation', 'otherRelation')->find(1);
$model2 = $model1::fresh('relation', 'otherRelation');

This is because fresh will not use func_get_args, but only pass the first parameter on to with(), so otherRelation is just dropped. To make them return the same result, you have to use an array when calling fresh():

$model2 =  $model1::fresh(['relation', 'otherRelation']);

I think it would be helpful if the $with parameter was used in the same way in both methods.

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

No branches or pull requests

1 participant