定制 mark-villudo/login-activiy-logs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mark-villudo/login-activiy-logs

Composer 安装命令:

composer require mark-villudo/login-activiy-logs

包简介

Laravel package API for user login using sunctum

README 文档

README

Laravel package to log each user's activity in the system and include api token based login using sanctum

Installation

Require this package with composer.

composer require mark-villudo/login-activiy-logs

Publish the Sanctum configuration and migration files using the vendor:publish Artisan command. The sanctum configuration file will be placed in your application's config directory:

php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"

Finally, you should run your database migrations. Sanctum will create one database table in which to store API tokens:

php artisan migrate

To begin issuing tokens for users, your User model should use the Laravel\Sanctum\HasApiTokens trait:

use Laravel\Sanctum\HasApiTokens;
 
class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;
}

Activity Logs

Setup Migrations and Model

Make model with migration file at the same time.
Note: At the package the model used is under "App\Models" then please do so.

php artisan make:model Models/ActivityLog -m

Activity Logs Table Structure

<?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');
    }
}

Migrate table using composer and it's automatically create table in the database

php artisan migrate

Usage

  //Parameter details (userType , action, description)
  storeActivity('Admin', 'Update Profile', 'Update Profile Settings');

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-10-28