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 REQUEST] use correct path for referenced model #5

Closed
subutux opened this issue May 4, 2022 · 1 comment · Fixed by #6
Closed

[FEATURE REQUEST] use correct path for referenced model #5

subutux opened this issue May 4, 2022 · 1 comment · Fixed by #6
Assignees

Comments

@subutux
Copy link

subutux commented May 4, 2022

Is your feature request related to a problem? Please describe.

When generating a Policy for a Model with for example:

artisan make:policy --context=OnCall --model=CronOnCallSchedule CronOnCallSchedulePolicy

The generated file is in the right location but the model use still points to the wrong location (In this case App\Models\CronOnCallSchedule instead of App\Domain\OnCall\Models\CronOnCallSchedule

Describe the solution you'd like

By default, point it to the nearest model according to the context given. In this case app\Domain\OnCall\Model\CronOnCallSchedulePolicy

Describe alternatives you've considered

providing the full model path works:

artisan make:policy --context=OnCall --model=App\Domain\OnCall\Models\CronOnCallSchedule CronOnCallSchedulePolicy

but is still a hassle to write out the full path.

Additional context

None. If you have any specific questions, shoot!

Thank you for this helpful tool!

allysonsilva added a commit that referenced this issue May 5, 2022
- When passing the `--model` options together with the `--context` option then the `use` statement in the policy must follow the context namespace, not the laravel pattern.
- When not using the `--context` option, only the `--model` option, the model must be created in the default Laravel folder

closes #5
allysonsilva added a commit that referenced this issue May 5, 2022
- When passing the `--model` options together with the `--context` option then the `use` statement in the policy must follow the context namespace, not the laravel pattern.
- When not using the `--context` option, only the `--model` option, the model must be created in the default Laravel folder

closes #5
allysonsilva added a commit that referenced this issue May 5, 2022
- When passing the `--model` options together with the `--context` option then the `use` statement in the policy must follow the context namespace, not the laravel pattern.
- When not using the `--context` option, only the `--model` option, the model must be created in the default Laravel folder

closes #5
allysonsilva added a commit that referenced this issue May 5, 2022
- When passing the `--model` options together with the `--context` option then the `use` statement in the policy must follow the context namespace, not the laravel pattern.
- When not using the `--context` option, only the `--model` option, the model must be created in the default Laravel folder

closes #5
@allysonsilva
Copy link
Owner

Hi @subutux, thanks for using this package and thanks for your improvement recommendation.

I implemented it in both versions 8 and 9 of Laravel. Now you can use it as you like 😉

For more details, see the release at v1.1.0 for Laravel 8 and v2.1.0 for Laravel 9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants