daravel_activitylog
English ยท Bahasa Indonesia
Model change history and an activity log for Daravel,
in the activity_log table of spatie/laravel-activitylog
v4: a Laravel application using Spatie and a Daravel application share the
table, and each reads the activities the other wrote.
dart pub add daravel_activitylog
// bootstrap/app.dart
import 'package:daravel_activitylog/daravel_activitylog.dart';
Application createApp() => Application.configure(basePath: '.')
.withActivityLog()
.withMigrations([...migrations, const CreateActivityLogTable()])
// ...
.create();
final class Assessment extends Model with LogsActivity {
static final ModelDefinition<Assessment> definition = ModelDefinition(
table: 'assessments',
factory: Assessment.new,
observers: [ActivityLogObserver<Assessment>()],
);
// ...
@override
LogOptions get activitylogOptions =>
LogOptions.defaults().logOnly(['score', 'status']).logOnlyDirty();
}
await exam.update({'score': 95}); // {attributes: {score: 95}, old: {score: 60}}
await activity('security').performedOn(exam).log('Exam locked');
await exam.activities().latest().get();
LogsActivityrecordscreated,updatedwith old values,deletedandrestoredas Spatie does, with Spatie'sLogOptions(logOnly, relation and JSON attributes,logOnlyDirty,dontSubmitEmptyLogs, ...).activity()with placeholders, the request's user as causer,LogBatch.within,ActivityLog.withoutLogs, andActivitywith Spatie's scopes;activitylog:clean.- Activities are written in the model's transaction, and a disabled log or a batch lasts for one callback, not the whole process.
- Tested on SQLite, PostgreSQL and MariaDB, and against Laravel 12 with Spatie 4.10.
Documentation: github.com/daravel-dev/daravel/blob/main/docs/guide/activitylog.md.
License and trademarks
MIT. "Laravel" is a trademark of Laravel Holdings Inc.; "Dart" is a trademark of Google LLC. spatie/laravel-activitylog is Spatie's MIT-licensed package; Daravel only shares its database layout. Daravel is an independent project, not affiliated with or endorsed by any of them.
Libraries
- commands
- The
activitylog:cleancommand, forbootstrap/commands.dart: - daravel_activitylog
- An activity log for Daravel (Blueprint #38) on spatie/laravel-activitylog
v4's
activity_logtable, so a Laravel application can share it: model changes with their old values, activities logged by hand, causers, batches.