mark-villudo / activity-logs
此包的最新版本(dev-master)没有可用的许可证信息。
Laravel用户活动日志的API包
dev-master
2019-11-26 01:21 UTC
Requires
- php: >=7.0.0
- jenssegers/agent: ^2.6
This package is auto-updated.
Last update: 2024-09-19 08:55:48 UTC
README
Laravel包,用于记录系统中每个用户的活动。
安装包后的使用
storeActivity('user type' , 'User Action', 'Description');
安装
使用Composer安装此包。
composer require mark-villudo/activity-logs
设置迁移和模型
使用迁移文件同时创建模型。
注意:在此包中使用的模型位于 "App\Models" 下,因此请按照此方式操作。
php artisan make:model Models/ActivityLog -m
活动日志表结构
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateActivityLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('activity_logs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('user_id')->nullable();
$table->string('type', 32)->nullable();
$table->text('action'); //required
$table->text('description')->nullable();
$table->string('ip_address', 64)->nullable();
$table->text('device')->nullable();
$table->text('platform')->nullable();
$table->text('browser')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('activity_logs');
}
}
使用Composer迁移表,它会自动在数据库中创建表
php artisan migrate
使用方法
//Parameter details (userType , action, description)
storeActivity('Admin', 'Update Profile', 'Update Profile Settings');
许可证
MIT许可证(MIT)。请参阅许可证文件获取更多信息。