Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ASYOU's avatar
Level 3

Set custom created_at value in Model::create()

On certain operations using Model::create() I want to set a custom creation date. But during the operation of the main functionality, it is necessary that the date, as before, would be set by itself. Those. set $timestamp = false and write your own mutator is not suitable for me as it will affect the rest of the system. How can I set this value only for a specific operation?

0 likes
5 replies
CrastyCrap's avatar

you can add ur custom col in table then make observer on creation to add value for this col in your conditions

ASYOU's avatar
Level 3

Found another option similar to the one above. Model::make([attr]) Model->created_at = value; Model->save();

Please or to participate in this conversation.