spatie / laravel-query-builder

Easily build Eloquent queries from API requests
https://spatie.be/docs/laravel-query-builder
MIT License
4.02k stars 395 forks source link

Create from mixes static and self #797

Closed olliescase closed 1 year ago

olliescase commented 2 years ago

https://github.com/spatie/laravel-query-builder/blob/9b7bf9123a66ddd38e0e2e9c1138b69c2325b11a/src/QueryBuilderRequest.php#L32

Is there a reason why the fromRequest method creates a new instance of self() rather than static() this means if you extend the class you have to then also override this function in order for it to return the extended class.

There may well be a "best practice" or use-case for this behaviour I'm not thinking of, but thought I'd question it as it struck me a little odd :)

AlexVanderbist commented 1 year ago

Hey @olliescase, you're right, this is probably an oversight. Feel free to PR the change from new self() to new static() and I'll merge it in :)

Thanks!