Ledger backups every in a while
- Auto logs all model classes
- Make new model as recordable
- Archive ledgers and daily sync
-
Install Tiks-Audit
composer require tnchalise/tiks
-
Edit the
config/app.php
to add following:'providers' => [ Altek\Accountant\AccountantServiceProvider::class, Tnchalise\Tiks\ServiceProvider::class, ],
-
Publish Tiks-Audit
php artisan vendor:publish --tag="accountant-configuration"
php artisan vendor:publish --tag="accountant-migrations"
php artisan vendor:publish --provider="Tnchalise\Tiks\ServiceProvider"
-
Adjust
.env
to have followingDB_AUDIT_HOST=**** DB_AUDIT_DATABASE=**** DB_AUDIT_USERNAME=**** DB_AUDIT_PASSWORD=**** AUDIT_ARCHIVE_INTERVAL=3 # Months
-
Set up secondary DB connection named
audit
inconfig/databas.php
'audit' => [ 'driver' => 'mysql', 'host' => env('DB_AUDIT_HOST', '127.0.0.1'), 'port' => env('DB_AUDIT_PORT', '3306'), 'database' => env('DB_AUDIT_DATABASE', 'forge'), 'username' => env('DB_AUDIT_USERNAME', 'forge'), 'password' => env('DB_AUDIT_PASSWORD', ''), 'unix_socket' => env('DB_AUDIT_SOCKET', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null, ],
-
Run Migrations
-
Repalce existing model to extend RecordableModel (optional)
sh sh/make-model-auditable.sh
from root directory, if necessary adjust path insh/make-model-auditable.sh
php artisan make:recordable-model <name>
$schedule->command('php artisan archive:ledgers')->->saturdays();