定制 devyousef/visitor 二次开发

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

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

devyousef/visitor

最新稳定版本:v1.0.1

Composer 安装命令:

composer require devyousef/visitor

包简介

Provides an attribute to allow counting the number of visitors for multiple models within your Laravel app

README 文档

README

Provides an attribute to allow counting the number of visitors for multiple models within your Laravel app

Installation

You can install the package via composer:

composer require devyousef/visitor

You can publish the migrations with:

php artisan vendor:publish --provider="Devyousef\Visitor\Providers\VisitorServiceProvider" --tag="migrations"

After that run the migrations:

php artisan migrate

As with most Laravel packages, if you're using Laravel 5.5 or later, the package will be auto-discovered (learn more if this is new to you).

If you're using a version of Laravel before 5.5, you'll need to register the Rateable service provider. In your config/app.php add Devyousef\Visitor\Providers\VisitorServiceProvider to the end of the $providers array.

'providers' => [

    Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
    Illuminate\Auth\AuthServiceProvider::class,
    ...
    Devyousef\Visitor\Providers\VisitorServiceProvider::class,

],

Usage

In order to mark a model as "visitorable", import the Visitorable trait.

<?php

namespace App\Models;

use Devyousef\Visitor\Traits\Visitorable;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use Visitorable;
    //
}

Now, your model has access to a few additional methods.

Now to calculate the number of visitors when visiting a post, for example we use visit() . Note that the user must be added as a parameter:

$post = Post::first();
$user = Auth::user();
$post->visit($user);

Then to display the number of visitors we use visitorCount()

$postVisitor = Post::first()->visitorCount();
dd($postVisitor);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固