esign / laravel-auto-timestamps
此包已废弃,不再维护。未建议替代包。
为 MySQLGrammar 添加了 ON UPDATE CURRENT_TIMESTAMP 支持
1.0.0
2020-07-14 09:08 UTC
This package is auto-updated.
Last update: 2022-02-24 14:14:33 UTC
README
此包已不再维护
useCurrentOnUpdate 已合并到框架本身
$table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
Laravel Auto Timestamps
此包为 MySQL 数据库添加了自动更新时间戳的功能。
安装
您可以通过 composer 安装此包
composer require esign/laravel-auto-timestamps
如果您想定义在哪些数据库连接上迁移助手可用,可以发布配置文件
php artisan vendor:publish --provider="Esign\AutoTimestamps\AutoTimestampsServiceProvider"
用法
指定数据库连接
要指定迁移应在哪些数据库连接上可用,请编辑配置文件中的 connections 数组。默认使用 mysql 连接。
'connections' => [ 'mysql', ],
迁移
此包在蓝图类上提供了一个 ->useCurrentUpdate() 方法,该方法仅在针对 MySQL 数据库运行时触发。
包含了一个蓝图宏 ->autoTimestamps(),允许您快速设置自动更新的 created_at 和 updated_at 时间戳。您可以在配置文件中编辑此宏的名称。
$table->autoTimestamps(); // results in: $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->useCurrentUpdate();