When you use artisan
to make a new policy, and you provide it with a model, it will stub out all 7 resourceful policy methods for you.
It will always include methods like restore
and forceDelete
for you, even if your model doesn't use the SoftDeletes
trait.
I would recommend deleting those methods if they don't apply to your model. It's just noise.
But I'd go a step further, and make the same recommendation to delete other policy methods you don't plan on using.
By default, an empty policy method is evaluated as an authorization failure, so you aren't accidentally opening a security hole by deleting it and then checking it.
In the future, if you build a feature that needs one of those methods, add it at that point, but don't leave a bunch of empty methods around. The next developer that looks at the file (or even you in the future), won't know if it was left empty on purpose, or if it was a mistake.
If you really want to keep the method there, at least make it explicitly return false
to avoid confusion.
Here to help,
Joel
P.S. If you'd like development help from two devs that really care about writing maintainable Laravel apps, we would love to talk.