2678777127 发表于 2018-2-11 11:46:09


            方法一:
class User extends Model {
public $timestamps = false;//关闭自动维护
public static function boot() {
    parent::boot();
    #只添加created_at不添加updated_at
    static::creating(function ($model) {
      $model->created_at = $model->freshTimestamp();
      //$model->updated_at = $model->freshTimeStamp();
    });
}
}
页: [1]
查看完整版本: laravel ORM 只开启created_at的几种方法总结