Skip to main content

daravel_activitylog 1.25.0 copy "daravel_activitylog: ^1.25.0" to clipboard
daravel_activitylog: ^1.25.0 copied to clipboard

Model change history and an activity log for Daravel, on spatie/laravel-activitylog's activity_log table, so a Laravel application can share it.

Daravel

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();
  • LogsActivity records created, updated with old values, deleted and restored as Spatie does, with Spatie's LogOptions (logOnly, relation and JSON attributes, logOnlyDirty, dontSubmitEmptyLogs, ...).
  • activity() with placeholders, the request's user as causer, LogBatch.within, ActivityLog.withoutLogs, and Activity with 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: https://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.

0
likes
160
points
635
downloads

Documentation

Documentation
API reference

Publisher

verified publisherframework.daravel.dev

Weekly Downloads

Model change history and an activity log for Daravel, on spatie/laravel-activitylog's activity_log table, so a Laravel application can share it.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#audit #activity-log #logging #server #backend

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

args, collection, daravel, dartisan_cli

More

Packages that depend on daravel_activitylog