How to only use created_at in Laravel

后端 未结 17 2067
自闭症患者
自闭症患者 2020-12-07 18:20

I want only use created_at , how to do it?

I know:

This can custom timestamps name

const CREATED_AT = \'created\';
const UPDATED_AT = \'updat         


        
17条回答
  •  抹茶落季
    2020-12-07 19:15

    Since Laravel 5.*

    Model:

    //  Disable updated_at (only created_at)
    class Book extends Model
    {
         const UPDATED_AT = null;
    
         /* ... */
    }
    

    Migration:

    Schema::create('books', function (Blueprint $table): void {
        /* ... */
        $table->timestampTz('created_at')->nullable();
    });
    

提交回复
热议问题