The package can be installed via composer:
composer require spatie/laravel-activitylog
The package will automatically register the service provider.
If you want your activities to be stored in a special database connection you can define ACTIVITY_LOGGER_DB_CONNECTION
in your .env
file.
After you've configured everything you should clear the application config cache via artisan config:clear
.
You can publish the migration with:
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
After the migration has been published you can create the activity_log
table by running the migrations:
php artisan migrate
You can optionally publish the config file with:
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-config"
This is the contents of the published config file:
return [
'enabled' => env('ACTIVITY_LOGGER_ENABLED', true),
'delete_records_older_than_days' => 365,
'default_log_name' => 'default',
'default_auth_driver' => null,
'subject_returns_soft_deleted_models' => false,
'activity_model' => \Spatie\Activitylog\Models\Activity::class,
'table_name' => 'activity_log',
];