madhurasri/laravel-activitylog-mongodb
最新稳定版本:1.0.1
Composer 安装命令:
composer require madhurasri/laravel-activitylog-mongodb
包简介
This is an extended version of the popular spatie/laravel-activitylog package designed to store data in MongoDB databases.
README 文档
README
Log activity inside your Laravel app with MongoDB support
This is an extended version of the popular spatie/laravel-activitylog package which allows you to easily log activities of your Laravel applications, such as user logins, profile updates, and more. It can also automatically log model events. This extended package allows you to store all activity in a MongoDB collection.
Installation
You can install the package via composer:
composer require madhurasri/laravel-activitylog-mongodb
The package will automatically register itself.
You can publish the config file with:
php artisan vendor:publish --provider="Madhurasri\Activitylog\ActivitylogServiceProvider" --tag="activitylog-config"
Usage
Here's a demo of how you can use it:
activity()->log('Look, I logged something');
You can retrieve all activity using the Madhurasri\Activitylog\Models\Activity model.
Activity::all();
Here's a more advanced example:
activity() ->performedOn($anEloquentModel) ->causedBy($user) ->withProperties(['customProperty' => 'customValue']) ->log('Look, I logged something'); $lastLoggedActivity = Activity::all()->last(); $lastLoggedActivity->subject; //returns an instance of an eloquent model $lastLoggedActivity->causer; //returns an instance of your user model $lastLoggedActivity->getExtraProperty('customProperty'); //returns 'customValue' $lastLoggedActivity->description; //returns 'Look, I logged something'
Here's an example on event logging.
$newsItem->name = 'updated name'; $newsItem->save(); //updating the newsItem will cause the logging of an activity $activity = Activity::all()->last(); $activity->description; //returns 'updated' $activity->subject; //returns the instance of NewsItem that was saved
Calling $activity->changes() will return this array:
[ 'attributes' => [ 'name' => 'updated name', 'text' => 'Lorum', ], 'old' => [ 'name' => 'original name', 'text' => 'Lorum', ], ];
Documentation
You'll find the documentation of original package on https://spatie.be/docs/laravel-activitylog/introduction.
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the activity log mongodb pakcage? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.
Testing
composer test
Changelog
Please see CHANGELOG for more information about recent changes.
Credits
And a special thanks to Caneco for the logo and Ahmed Nagi for all the work he put in v4.
Support spatie
Spatie invest a lot of resources into creating best in class open source packages. You can support them by buying one of their paid products.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 376
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-19
