定制 moecasts/laravel-user-login-log 二次开发

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

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

moecasts/laravel-user-login-log

Composer 安装命令:

composer require moecasts/laravel-user-login-log

包简介

A package for log user login info

README 文档

README

Document

English 中文

Build Status Scrutinizer Code Quality Code Coverage Code Intelligence Status Code Intelligence Status

Feature

  • Log user login records
  • Analyse user login logs

Installation

Required

  • PHP 7.0+
  • Laravel 5.5+

You can install the package using composer

composer require moecasts/laravel-user-login-log

If you are using Laravel < 5.5, you need to add provider to your config/app.php providers array:

Moecasts\Laravel\UserLoginLog\UserLoginLogServiceProvider,

Publish the mirgrations file:

php artisan vendor:publish --tag=laravel-user-login-log-migrations

As optional if you want to modify the default configuration, you can publish the configuration file:

php artisan vendor:publish --tag=laravel-user-login-log-config

And create tables:

php artisan migrate

Configurations

return [
    /**
     * cache avtive time (seconds)
     */
    'expire' => 300,
];

Usage

Firstly, add LoginLoggable trait to your authenticatable model.

use Moecasts\Laravel\UserLoginLog\Traits\LoginLoggable;

class User extends Authenticatable
{
    use LoginLoggable;
}

Next, simply register the newly created class after auth middleware in your middleware stack.

// app/Http/Kernel.php

class Kernel extends HttpKernel
{
    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        // ...
        'login.log' => \Moecasts\Laravel\UserLoginLog\Middleware\UserLoginLogMiddleware::class,
    ];

    // ...
}

Finally, use the middleware:

Route::get('hello')->middleware(['auth', 'login.log']);

Methods

Get user's logs

$user = new User;
$user->loginLogs;

Create user login log

$user = new User;
$user->createLoginLog();

Log when user newly login

This function is depet on cache, when your newly login, it will set a cache with for $seconds or default config ( loginlog.expire ) seconds when $seconds is not set.

$user = new User;
// $user->logLogin($seconds = null)
$user->logLogin();

Check is new login

$user = new User;
$user->isNewLogin();

Let's enjoy coding!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固