laravel-nestedset icon indicating copy to clipboard operation
laravel-nestedset copied to clipboard

Move query builder logic to trait

Open riesjart opened this issue 8 years ago • 2 comments

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.

riesjart avatar Jun 28 '17 12:06 riesjart

So is this problem going to be fixed? I've met the same problem. I have trait that re-defines newEloquentBuilder method...

malyusha avatar May 31 '18 16:05 malyusha

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.

ievgenklymenko avatar Mar 06 '23 11:03 ievgenklymenko