yektadg/laravel-log-activity-mongodb 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

yektadg/laravel-log-activity-mongodb

最新稳定版本:v1

Composer 安装命令:

composer require yektadg/laravel-log-activity-mongodb

包简介

README 文档

README

Log activity inside your Laravel app

Log Panel

initializition config :

By default, activities will be saved to the 'yektalog' database in the 'log' collection if no MongoDB configurations are set in the '.env' or 'config/database.php' files. To change the database to your custom one, add the following lines to the '.env' file in your Laravel application :

MONGODB_CONNECTION=mongodb

MONGODB_HOST=myhost

MONGODB_PORT=27017

MONGODB_DATABASE=yourdatabase

installation :

  1. remove 'composer.lock' file and 'vendor' folder
  2. run 'composer install' command
  3. run 'composer require yektadg/laravel-log-activity-mongodb' command
  4. in each models that want to log it's activity you shuld add the following options :
  • add YektaLog trait like this :

      class Test extends Model
          {
              use YektaLog;
              
              protected $foreignKeys = [
                      'App\Models\Ticket' => 'ticket_id', 
                      'App\Models\User' => 'user_id',
              ];
              public function getForeignKeys(){
                      return $this->foreignKeys;
              }
              public function getShowRoute(){
                      return "admin.user.show";
              }
              ....
          }
    
  • Add a 'protected $foreignKeys' array to your model like this:

    protected $foreignKeys = [ 'App\Models\Ticket' => 'ticket_id', 'App\Models\User' => 'user_id', ]

    'ticket_id' and 'user_id' are the referenced fields in this model, and 'App\Models\Ticket' and 'App\Models\User' are their corresponding classes.

  • Add a 'getForeignKeys()' method to your model that returns the 'foreignKeys' variable:

    public function getForeignKeys(){ return $this->foreignKeys; }

    This method will allow you to retrieve the 'foreignKeys' array.

  • Add a 'getShowRoute()' method to your model that returns a route name. this route will saved in database and You can use this method in your views to create a link to the logged object:

    public function getShowRoute(){ return "test.show"; }

    if you don't need this route, return an empty srting like this:

    public function getShowRoute(){ return ""; }

  • Use 'Yektadg\LaravelLogActivityMongodb\Models\Log' to access the Log Model like bellow :

    use Yektadg\LaravelLogActivityMongodb\Models\Log; $logs = Log::where('created_at' ,'!=', null);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固