laravel-nestedset
laravel-nestedset copied to clipboard
Move query builder logic to trait
Using a trait for the Eloquent query builder logic allows the developer to combine it with other Eloquent builder customisations, e.g. from other packages.
For example, I use my own custom builder class App\Database\Eloquent\Builder. It can only extend one class (preferably the Illuminate base class), so when I want to combine multiple packages and own customisations, using traits would be the solution. This resembles what you already did with the NodeTrait for the Model class.
While using the trait, the nested set Builder class just remains in place so everything remains compatible.
So is this problem going to be fixed? I've met the same problem. I have trait that re-defines newEloquentBuilder method...
This would be amazing!
The practic of extending builder through newEloquentBuilder is becoming more and more common. Package owners and project devs - everybody wants to use their own builders.
This would help greatly and it doesn't look hard to do (just moving everything to a Trait or am I missing something?..) - neither does it ruin backward compatibility.