在model层做转换,如下:
/** * The attributes that should be cast to native types. * * @var array */ protected $casts = ['id' => 'integer', 'category_id' => 'integer', 'version_code' => 'integer', 'valuedomain_id' => 'integer','effective_date' => 'datetime:Y-m-d','expiration_date' => 'datetime:Y-m-d'];
如代码中的effective_date