Add and enforce shipping:manage permission#2408
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds permission enforcement to the table rate shipping resources in the Lunar admin panel by introducing a shipping:manage permission. Previously, these resources had no permission checks, which meant they were accessible to all authenticated users regardless of their assigned permissions.
Changes:
- Added
shipping:managepermission property to three shipping-related Filament resources - Created a migration to register the new permission in the database
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/table-rate-shipping/src/Filament/Resources/ShippingZoneResource.php |
Added $permission property to enforce shipping:manage permission |
packages/table-rate-shipping/src/Filament/Resources/ShippingMethodResource.php |
Added $permission property to enforce shipping:manage permission |
packages/table-rate-shipping/src/Filament/Resources/ShippingExclusionListResource.php |
Added $permission property to enforce shipping:manage permission |
packages/table-rate-shipping/database/migrations/2026_02_16_100000_add_can_manage_permission.php |
Migration to create the shipping:manage permission with proper guard handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| use Lunar\Base\Migration; | ||
| use Spatie\Permission\Models\Permission; | ||
|
|
||
| class AddCanManagePermission extends Migration |
There was a problem hiding this comment.
Can we use anonymous classes so it's consistent across the package :)
return new class extends Migration
{|
Thanks @ryanmitchell only a couple of small bits, the other being the name of the migration. Can this be something like |
|
@alecritson both changes made |
At the moment there is no enforcement of a permission for the table rate shipping resources in the panel, this PR adds that.