1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-06-21 18:44:06 +00:00
tenancy/resources/boost/skills/laravel-tenancy/references/resource-syncing.md

32 lines
958 B
Markdown

# Resource Syncing Reference
Use this when syncing central resources into tenant contexts.
## Source Files
- `src/ResourceSyncing/*`
- `assets/resource-syncing-migrations/*`
- `assets/TenancyServiceProvider.stub.php`
## Setup
Publish resource syncing migration:
```bash
php artisan vendor:publish --provider="Stancl\Tenancy\TenancyServiceProvider" --tag=resource-syncing-migrations
php artisan migrate
```
## Main Pieces
- `tenant_resources` table.
- `ResourceSyncing` classes and listeners.
- `SyncMaster`, `Syncable`, `TenantPivot`, `TenantMorphPivot`.
- Events such as `SyncedResourceSaved`, `SyncedResourceDeleted`, `CentralResourceAttachedToTenant`.
## Rules
- Use package events/listeners instead of custom tenant loops.
- Keep central and tenant resource lifecycles explicit.
- Configure soft-delete query behavior in the application `TenancyServiceProvider` when needed.
- Test create, update, delete, restore, attach, and detach behavior.