Looking to hire Laravel developers? Try LaraJobs

laravel-auto-timestamps maintained by esign

Description
Adds ON UPDATE CURRENT_TIMESTAMP support for MySQLGrammar
Last update
2022/01/24 15:01 (dev-master)
License
Links
Downloads
7 372

Comments
comments powered by Disqus

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();