承接 kerattila/laravel-track-author 相关项目开发

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

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

kerattila/laravel-track-author

最新稳定版本:v2.0.4

Composer 安装命令:

composer require kerattila/laravel-track-author

包简介

Extension to add created_by, updated_by and deleted_by columns to Eloquent models.

README 文档

README

This package allow you to track the user who created, deleted and deleted eloquent modelss.

Install and configure

You can install the package via composer:

composer require kerattila/laravel-track-author

Publish the config file by running:

php artisan vendor:publish --provider="Kerattila\TrackAuthor\TrackAuthorServiceProvider"

After publishing configuration file, adjust the values accordingly your needs:

<?php

return [
    'models' => [
        'user' => \App\User::class
    ],
    'columns' => [
        'createdByColumnName' => 'created_by',
        'updatedByColumnName' => 'updated_by',
        'deletedByColumnName' => 'deleted_by',
    ]
];

Model and migration configuration

Migrations:

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

Schema::table('posts', function (Blueprint $table) {
    // this will automatically add created_by, updated_by and updated_by nullable columns
    $table->trackAuthor();
});
            

Models

You can add the Kerattila\TrackAuthor\Traits\TrackAuthor trait to your models or just add one of the CreatedBy, UpdatedBy, DeletedBy traits.

Example:

<?php

namespace App;

// use Kerattila\TrackAuthor\Traits\CreatedBy;
// use Kerattila\TrackAuthor\Traits\UpdatedBy;
// use Kerattila\TrackAuthor\Traits\DeletedBy;
use Kerattila\TrackAuthor\Traits\TrackAuthor;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use TrackAuthor;
    // use CreatedBy, UpdatedBy, DeletedBy;
}

Relations

Relations are the type of BelongsTo and can be accessed as follows:

$post = \App\Post::find(1);
$createdBy = $post->createdBy;
$updatedBy = $post->updatedBy;
$deletedBy = $post->deletedBy;

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固