We love your package, however it falls short whenever there's a third party model which happens to have the same name as ours
This might be an "us" issue, and not something relevant for this package, however i thought i would contribute if anyone else had the same issues:
Context:
We use a Laravel Module package which allows us to seperate our code into modules and keep logic more tightly locked up. a benefit of this is that when it becomes nessecary we can simply turn the entire module into a package and share it to external partners and such. ( Package in question is: https://github.com/InterNACHI/modular )
Problem:
We have 3 Models all names Product
Each are namespaced into their own module
Example:
app/Models/Product
app-modules/Shopify/Models/Product
app-modules/Struct/Models/Product
when using this package it is only possible for us to register / generate a policy for one module as they are all put into the same directory.
So a "ShopifyProduct" would turn into ProductPolicy with the model pointing to the module's model
In the AuthServiceProvider we added each custom model with a corresponding policy
with the thought that Shield would edit the policy in the module folder, and while we understand why not it was still not possible for Shield to add a sub folder to the app/Policies folder
ideally we wanted something like
app/Policies/Shopify/ProductPolicy
app/Policies/Struct/ProductPolicy
app/Policies/ProductPolicy
however the generate command simple overwrote the same ProductPolicy 3 times and the last one registered won :(
The patch below solves the issue by looking for a folder and then using Sub Folder logic to separate each policy into their own folder
Greetings!
We love your package, however it falls short whenever there's a third party model which happens to have the same name as ours
This might be an "us" issue, and not something relevant for this package, however i thought i would contribute if anyone else had the same issues:
Context: We use a Laravel Module package which allows us to seperate our code into modules and keep logic more tightly locked up. a benefit of this is that when it becomes nessecary we can simply turn the entire module into a package and share it to external partners and such. ( Package in question is: https://github.com/InterNACHI/modular )
Problem:
We have 3 Models all names Product Each are namespaced into their own module
Example:
when using this package it is only possible for us to register / generate a policy for one module as they are all put into the same directory.
So a "ShopifyProduct" would turn into ProductPolicy with the model pointing to the module's model
In the
AuthServiceProvider
we added each custom model with a corresponding policyie:
with the thought that Shield would edit the policy in the module folder, and while we understand why not it was still not possible for Shield to add a sub folder to the
app/Policies
folderideally we wanted something like
however the generate command simple overwrote the same ProductPolicy 3 times and the last one registered won :(
The patch below solves the issue by looking for a folder and then using Sub Folder logic to separate each policy into their own folder
An idea could be to make it an option in the plugin to allow subfolder logic