'ID', 'created_at' => 'Created At', 'stopped_at' => 'Stopped At', 'user_id' => 'User ID', 'entity_type' => 'Entity Type', 'entity_id' => 'Entity ID', 'status' => 'Status', ]; } /** * @return array */ public function fields(): array { return [ 'id', 'user_id', 'created_at', 'stopped_at', 'entity_id', 'entity_type', 'delta' => function(){ return $this->getDelta(); }, 'deltaSeconds' => function(){ return $this->getDeltaSeconds(); }, 'status', ]; } /** * @return \DateInterval|false */ public function getDelta() { $create = date_create($this->created_at); $stopped = date_create($this->stopped_at); return date_diff($create, $stopped); } /** * @return int */ public function getDeltaSeconds(): int { $create = date_create($this->created_at); $stopped = date_create($this->stopped_at); return $stopped->getTimestamp() - $create->getTimestamp(); } /** * @return string[] */ public static function getStatusList(): array { return [ self::STATUS_ACTIVE => "Активен", self::STATUS_DISABLE => "Не активен", ]; } }