lakasir / user-logging-activity
user-logging-activity package provides easy to use functions to log the activities of the users of your app. It can also automatically log model events. All activity will be stored in the activity_log table.
Requires
- php: ^7.2.5
- illuminate/support: ^7.0.0
Requires (Dev)
- orchestra/testbench: ^5.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2022-08-15 16:28:56 UTC
README
The lakasir/user-logging-activity
package provides easy to use functions to log the activities of the users of your app. It can also automatically log model events. All activity will be stored in the activity_log table.
Installation
You can install the package via composer:
composer require lakasir/user-logging-activity
Publish migration and config file with:
php artisan log-activity:install php artisan migrate
Usage
First define which model you want to record:
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Lakasir\UserLoggingActivity\Traits\HasLog; class Purchasing extends Model { use HasLog; }
Use Lakasir\UserLoggingActivity\Facades\Activity;
facade:
Create simple log:
Activity::info('Logged In at '. now()->format('Y-m-d'));
Create more advaced log
$data = Purchasing::create($request->all()); Activity::modelable($data)->auth()->creating();
You can get all activity just use the Lakasir\UserLoggingActivity\Models\Activity
; model:
Activity::all();
Available chaining action method
creating()
for creating infoupdating()
for updating infosync()
for dispatch now action- You can set default queue action in
acitivity_log.queable
, if the value is false you didn't need this chaining, if true checkout the job laravel documentation
- You can set default queue action in
auth()
for authenticable user- Set default user model in
activity_log.user_model
- Set default user model in
modelable($model)
pass the related activity
Testing
under development
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email sheenazien08@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.