esign / laravel-auto-timestamps
Adds ON UPDATE CURRENT_TIMESTAMP support for MySQLGrammar
Installs: 2 185
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
This package is auto-updated.
Last update: 2022-02-24 14:14:33 UTC
README
THIS PACKAGE IS NOT MAINTAINED ANYMORE
useCurrentOnUpdate
has been pr'd into the framework itself:
$table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
Laravel Auto Timestamps
This package adds the ability to use auto-updating timestamps for MySQL databases.
Installation
You can install the package via composer:
composer require esign/laravel-auto-timestamps
If you want to define the database connections on which the migration helpers should be available, you could publish the config file:
php artisan vendor:publish --provider="Esign\AutoTimestamps\AutoTimestampsServiceProvider"
Usage
Specifying database connections
To specify the database connections on which the migrations should be available, edit the connections array in the config file. The mysql connection is used by default.
'connections' => [ 'mysql', ],
Migrations
This package provides a ->useCurrentUpdate()
method on the blueprint class, which only triggers when running against a MySQL database.
A blueprint macro ->autoTimestamps()
is included that will allow you to quickly set up auto-updating created_at
and updated_at
timestamps. You may edit the name of this macro in the config file.
$table->autoTimestamps(); // results in: $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->useCurrentUpdate();