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

[Feature] Change app namespace call in commands #243

Open
danielcarney96 opened this issue Mar 28, 2023 · 2 comments
Open

[Feature] Change app namespace call in commands #243

danielcarney96 opened this issue Mar 28, 2023 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@danielcarney96
Copy link

Is your feature request related to a problem? Please describe.
We are using a non-standard folder structure for our app in which the searchable models live in a different namespace to the namespace defined in laravel's Application.php.

Because of this the flush and import commands do not pickup our models since they use the method app()->getNamespace().

Describe the solution you'd like
Either a different method for finding the models or a way to configure the namespace to look in.

algolia/scout-extended uses an approach which looks at the root composer.json file and collects the autoload mappings. Perhaps with some changes to ignore the common database namespaces this would be a good approach. See: https://github.com/algolia/scout-extended/blob/bf3d7876fadaaa1cdbce3a09cfd256227406a3fc/src/Helpers/SearchableFinder.php#L116

Alternatively this could be managed via config. Perhaps with a default value of App\\ or app()->getNamespace().

Describe alternatives you've considered
We can't extend the existing commands so as a workaround we have just copied them as a way of overwriting, then have changed the namespace function call. But this is not ideal as we will need to keep it up to date.

@danielcarney96 danielcarney96 added the enhancement New feature or request label Mar 28, 2023
@matchish
Copy link
Owner

Yeah following algolia-extended approach is good idea. Feel free to open PR

@matchish matchish added the help wanted Extra attention is needed label Mar 29, 2023
@danielcarney96
Copy link
Author

Sure, will get around to it when I can

matchish added a commit that referenced this issue Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants