定制 michaeljmeadows/created-by 二次开发

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

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

michaeljmeadows/created-by

最新稳定版本:v2.1.0

Composer 安装命令:

composer require michaeljmeadows/created-by

包简介

A simple trait to add User relationships to Eloquent models to track creation, updating, and deletion.

README 文档

README

A simple trait to add User relationships to Eloquent models to track creation, updating, and deletion.

Installation

You can install the package via composer:

composer require michaeljmeadows/created-by

Usage

Assuming you already have a users table, add the following fields to the model migration:

$table->foreignId('created_by')->nullable()->constrained('users');
$table->foreignId('updated_by')->nullable()->constrained('users');
$table->foreignId('deleted_by')->nullable()->constrained('users');

If you're using UUID or ULID ID fields, replace foreignId in the above with foreignUuid or foreignUlid fields accordingly

Once the fields are added to the model, you can simply include the trait in your model's definition:

<?php

namespace App\Models;

use michaeljmeadows\Traits\CreatedBy;
use Illuminate\Database\Eloquent\Model;

class NewModel extends Model
{
    use CreatedBy;

BelongsTo relationships to the User will now be accessible on your model:

$creator = $newModel->createdBy;
$updater = $newModel->updatedBy;
$deleter = $newModel->deletedBy;

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固