I need to send to database a date format like: DD-MM-YYYY. Or some way to format in frontend using Edge template
class AtendimentoSchema extends Schema {
up () {
this.create('atendimentos', (table) => {
table.increments()
table.date('data_emissao')
table.timestamps()
})
}
down () {
this.drop('atendimentos')
}
}
I've tried
class Atendimento extends Model {
static formatDates (field, value) {
if (field === 'data_emissao') {
return value.format('DD-MM-YYYY')
}
return super.formatDates(field, value)
}
}
** JSON output**
{
"data_emissao": "2020-02-14",
"id": 2
}