class Robot extends Model
{
public function afterFetch()
{
if ($this->expiration_at !== null)
$this->expiration_at = \DateTime::createFromFormat('Y-m-d', $this->expiration_at);
}
public function beforeSave()
{
if ($this->expiration_at !== null)
$this->expiration_at = $this->expiration_at->format('Y-m-d');
}
}
return Robot::findFirst(1)->toArray();
{
expiration_at: {
date: "2019-12-22 11:12:19.000000",
timezone_type: 3,
timezone: "UTC"
}
}
мне нужно преобразовать дату перед функцией -> toArray(), если такое событие ? I need to convert the date before the function -> toArray (), if such an event?
я хочу получить: I want to receive:
{expiration_at:"2019-12-22"}