I have an object model that has an attribute named "code" that is generated based on object id. The problem is I cannot access object id in my controller before it is stored because it is auto increment. Is there a simple way to add "code" attribute when storing object?
The "code" attribute would contain id with leading zeros like this:
str_pad($object_id, 6, '0', STR_PAD_LEFT);