lundi 26 septembre 2016

laravel new column default value created_at value

I have a table with orders like:

Order

id
created_at
shipped_at
billed_at

the shipped_at is on the packing list and the billed_at on the invoice.The fields shipped_at and billed_at are recently added.

When I create the order sometimes I want to give the created_at date a custom date if the order is for the future (i know this wasnt the original idea behind created_at). What I want is that the value of created_at is copied to shipped_at and billed_at on creation, because i sometimes use a custom value for created_at I cant just use current date time.

I can create an Order on 5 different locations so it would be nice if I could just create one function to copy these values instead of call the same function from 5 locations where i create an order.

Is there a clever location in the laravel framework to copy the value of created_at to shipped_at?

thoughts: Normaly I would think an event like saving would be best but the created_at is created after the save, is it possible to update/save in the saved event or would this create an infinit loop of saving?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire