allysonsilva / laravel-artisan-domain-contexts

A Laravel Package for using Artisan commands in Domain Contexts
MIT License
31 stars 4 forks source link

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

Closed subutux closed 2 years ago

subutux commented 2 years ago

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 commented 2 years ago

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.