Why isn't the 'deleted_at' datetime field auto-casted?

Posted 6 months ago by DevMaster

I see (from tinkering with Nova) that the 'deleted_at' datetime field (as generated by $table->softDeletes(); in a migration) is not auto-casted to a DateTime or Carbon instance.

BUT the $table->timestamps(); datetime fields are indeed auto-casted by Laravel: "By default, Eloquent will convert the created_at and updated_at columns to instances of Carbon, which extends the PHP DateTime class".

So I am simply curious to hear if there is any special practical or technical reason to exclude 'deleted_at' from auto-casting?

Many thanks, Dev Master

Please sign in or create an account to participate in this conversation.