Set the database_connection key in config/activitylog.php to null. This makes activitylog use the default connection.
Publish the migrations and move them to database/migrations/tenant. (And, of course, don’t forget to run artisan tenants:migrate.)
For the central app
Set the database_connection key in config/activitylog.php to the name of your central database connection.
laravel-permission
Install the package like usual, but publish the migrations and move them to migrations/tenant:
Next, add the following listeners to the TenancyBootstrapped and TenancyEnded events to events() in your TenancyServiceProvider:
Alternatively, create a bootstrapper:
The reason for this is that spatie/laravel-permission caches permissions & roles to save DB queries, which means that we need to separate the permission cache by tenant. We also need to reset the cache key when tenancy ends so that the tenant’s cache key isn’t used in the central app.
laravel-medialibrary
To generate the correct media URLs for tenants, create a custom URL generator class extending Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator and override the getUrl() method:
Then, change the url_generator in the media-library config to the custom one (make sure to import it):
laravel-login-link
After installing the package, publish the config file:
After that, add your tenant identification middlewares to the config file’s middleware key: