Download the PHP package cerutti-maicon/laravel-activitylog-for-tenancy-for-laravel without Composer
On this page you can find all versions of the php package cerutti-maicon/laravel-activitylog-for-tenancy-for-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cerutti-maicon/laravel-activitylog-for-tenancy-for-laravel
More information about cerutti-maicon/laravel-activitylog-for-tenancy-for-laravel
Files in cerutti-maicon/laravel-activitylog-for-tenancy-for-laravel
Package laravel-activitylog-for-tenancy-for-laravel
Short Description A very simple activity logger to monitor users of your website or application by tenant, using laravel-for-tenancy
License MIT
Homepage https://github.com/CeruttiMaicon/laravel-activitylog-for-tenancy-for-laravel
Informations about the package laravel-activitylog-for-tenancy-for-laravel
Log activity inside your Laravel app
This project is a fork of spatie/laravel-activitylog
.
Now compatible with Laravel 10.
What we want with this fork is to make it possible for the logs not to be centralized in a single table. Over time, all system logs end up generating a table with many records, and to alleviate this problem, the proposal here is to use the package Tenancy for Laravel to create a second tenant , with the nomenclature having a _logs
suffix. And so making each tenant have 2 databases.
To proceed with the implementations of Logs you should still use the documentation from Spetie Laravel-activitylog.
The changes in this package were that an attribute for the useLogName
function must always be informed, as this attribute will define the name of the table to save the log data informed by the getActivitylogOptions
function applied to the model.
Installation
You can install the package via composer:
The package will automatically register itself.
You can publish the migration with:
Yes, this command remains the same
Compulsorily, you can publish the configuration file with:
Note that there are some extra settings
tenant_model
andtenant_seeder_model
. These settings are used to define the template that will be used to create the tenant and the template that will be used to create the tenant propagator. They must be met according to each project implementation.
Create the databases following the prefix pattern for the main tenants:
Example:
After publishing the migration, you can run the migrations with the following command:
The above command also generates the records of the tenants from logs in the tenants table of the application's central database.
Note that there is a run of a seeder that truncates the migrations table. Yes, this is done on purpose, so that the tables created in the tenant logs contain the same tables as the main tenant automatically, so the developer doesn't have to recreate other migrations for this function.
It is extremely important for this package to work that MultiActivity
is listed in the project configuration, it is thanks to this that the connections are switched between the main tenant and the log tenant.
Commands
The package comes with some artisan commands to run the migrations and seeder only for the main tenants, the tenant logs should work automatically:
Migrate for Tenant Logs
It must be run for each new table created in the main tenant, in order to be able to generate the logs for it.
Migrate for Tenant Main
It should be executed when the objective is to run migrations only for the main tenants.
This command lists all tenants in the system
Has
--tenants
option to run for a specific tenantHas
--class
and--tenants
option to run for a specific tenant
Warning
It is extremely discouraged to continue to use the native commands from the Tenancy for Laravel package.
For example:
This command does not differentiate between the main tenant and the log tenant
Because it is not making any difference between main tenant and log tenant, it would be at your own risk to run migrations from different migration directories (some more basic validations were implemented to prevent these types of errors, but only if you use the native commands of this one package).
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-activitylog-for-tenancy-for-laravel with dependencies
illuminate/config Version ^8.0 || ^9.0 || ^10.0
illuminate/database Version ^8.69 || ^9.27 || ^10.0
illuminate/support Version ^8.0 || ^9.0 || ^10.0
spatie/laravel-package-tools Version ^1.6.3