Laravel - Sum date from date saved in database

Asked

Viewed 349 times

0

Good afternoon Personal,

I am using Laravel, and I would like to create a method with a calculation, that from a date saved in the "dataSinistro" bank (which I will insert myself in a register) it search another field in the "days" bank and add these days in a new item in the table "datePrescricao".

I would like to use Carbon for this, but I’m not finding the functionality of Carbon that looks for information from the Bank and I’m not able to create something that works in this situation.

  • I confess that I was a little confused, but put the code you already have, so we can better understand your doubt.

1 answer

0


From what I understand, you want to add x days to a bank date

$dataPrescricao = Carbon::createFromFormat("!Y-m-d", $dataSinistro) // Cria uma instância do Carbon com a data do banco
    ->addDays($dias); // Adiciona x dias à data (executa ->modify("+$dias day"))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.