How to only use created_at in Laravel

后端 未结 17 2115
自闭症患者
自闭症患者 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 18:56

    My solution:

    class CreatePostsTable extends Migration {
    
       public function up() {
    
          Schema::create('posts', function(Blueprint $table){
    
             $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
       });
    }
    

    This works for me

提交回复
热议问题