jcrodsolutions/laravel-user-stamp 问题修复 & 功能扩展

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

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

jcrodsolutions/laravel-user-stamp

最新稳定版本:v1.0.7

Composer 安装命令:

composer require jcrodsolutions/laravel-user-stamp

包简介

Enables automatic user stamp on created_by and updated_by fields within a model.

README 文档

README

PHP Version Packagist Version Packagist Github

Enables automatic user stamp on created_by and updated_by fields within a model.

Usage

Inside any model having the created_by and/or updated_by fields you should use the trait as follows.

use Jcrodsolutions\LaravelUserStamp\App\Traits\UserStampTrait;
use Illuminate\Database\Eloquent\Model;

class  MyModel  extends  Model
{
	use  UserStampTrait;
	protected  $fillable = ['codename','name','created_by','updated_by'];
	// ...
}

Global defaults

Globally, the default field names the trait will try to populate are

  • active
  • created_by
  • updated_by

Whenever you want to change this just publish the vendor config file.

myproject# php artisan vendor:publish

Proceed by selecting the provider "Provider: Jcrodsolutions\LaravelUserStamp\UserStampServiceProvider".

Custom field names in a model

If you need to customize any of the fields in the model you should override the defaults by defining protected variables as the following example


use Jcrodsolutions\LaravelUserStamp\App\Traits\UserStampTrait;
use Illuminate\Database\Eloquent\Model;

class  MyModel  extends  Model
{
	use  UserStampTrait;
	protected  $fillable = ['codename','name','created_by','updated_by'];
	protected  static  $active = 'activo';
	protected  static  $createdBy = 'creado_por';
	protected  static  $updatedBy = 'actualizado_por';
	
	//...
}

License

MIT.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-05