承接 dinhdjj/visit 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dinhdjj/visit

最新稳定版本:v1.1.1

Composer 安装命令:

composer require dinhdjj/visit

包简介

Package to tracking visits of a given model

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Installation

You can install the package via composer:

composer require dinhdjj/laravel-visit

You can publish and run the migrations with:

php artisan vendor:publish --tag="visit-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="visit-config"

This is the contents of the published config file:

// config for dinhdjj/laravel-visit package
return [

    /**
     * Table name for visit logs
     */
    'table' => 'visits',

    /**
     * The model class name that will be used to store visit logs, must be a subclass of \Dinhdjj\Visit\Models\Visit
     */
    'model' => Dinhdjj\Visit\Models\Visit::class,
];

Usage

Use Visitable trait

The first thing you need to do is, to use Visitable trait.

class Post extends Model
{
    use \Dinhdjj\Visit\Traits\Visitable;
}

After that, you can use below methods to interact with the visit logs:

    $post = Post::first();

    $post->visitLogs() // relation to visit logs

    $post->visitLogs // collection of visit logs

    $builder = $post->visitLog(User::first()) // builder visit with user as visitor

    $builder->byIp(); // prevent duplicate visit by ip
    $builder->byVisitor(); // prevent duplicate visit by visitor

    $builder->interval(60*15) // prevent duplicate visit within 15 minutes, default is 60*15

    $visit = $builder->log(); // create visit to database

Use Visitor trait

The first thing you need to do is, to use Visitor trait.

class User extends Model
{
    use \Dinhdjj\Visit\Traits\Visitor;
}

After that, you can use below methods to interact with the visit logs:

    $user = Post::first();

    $user->visits() // relation to visit logs

    $post->visits // collection of visit logs

    $builder = $post->visit(Post::first()) // builder visit to post

    // ... same as above

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-18