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

Make package's logic scoped to queries via a config #18

Closed
piljac1 opened this issue Sep 25, 2020 · 2 comments
Closed

Make package's logic scoped to queries via a config #18

piljac1 opened this issue Sep 25, 2020 · 2 comments

Comments

@piljac1
Copy link

piljac1 commented Sep 25, 2020

This is not a bug, but and enhancement/idea. I was wondering if it would be possible to have a flag or string based config to determine if we want all builders to be Staudenmeir\LaravelCte\Query\Builder on app load or if we want to manually specify when we want to use this specific builder type by the help of a specific Builder class (or maybe a trait?). For example (I'd leave the naming up to you):

CteBuilder::from('tree')
    ->withRecursiveExpression('tree', $query)
    ->get();

I currently don't like the fact that all builders are overwritten because it makes the package a huge project dependency and most of my existing phpdoc comment blocks obsolete.

@staudenmeir
Copy link
Owner

You can disable auto-discovery in your composer.json:

"extra": {
    "laravel": {
        "dont-discover": [
            "staudenmeir/laravel-cte"
        ]
    }
},

And then instantiate the query builder manually:

$builder = new \Staudenmeir\LaravelCte\Query\Builder(\DB::connection());

$result = $builder->from('tree')
    ->withRecursiveExpression('tree', $query)
    ->get();

Does that solve your issue?

@piljac1
Copy link
Author

piljac1 commented Sep 28, 2020

That works too ! Thanks 👍

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

2 participants