items = $db->prefix . 'schedulereed_booking_items'; } /** * Insert a booking with its items. * * @param array $booking Booking fields (hydrated names). * @param array> $items Items (hydrated names). * @return int Booking ID. */ public function create( array $booking, array $items ): int { $now = self::now(); $this->db->insert( $this->table, array( 'uid' => (string) $booking['uid'], 'token' => (string) $booking['token'], 'customer_id' => (int) ( $booking['customer_id'] ?? 0 ), 'status' => (string) $booking['status'], 'source' => (string) ( $booking['source'] ?? 'online' ), 'starts_at' => self::dt( (int) $booking['start'] ), 'ends_at' => self::dt( (int) $booking['end'] ), 'total_minor' => (int) ( $booking['total'] ?? 0 ), 'paid_minor' => 0, 'deposit_minor' => (int) ( $booking['deposit'] ?? 0 ), 'currency' => (string) $booking['currency'], 'payment_method' => (string) ( $booking['payment_method'] ?? '' ), 'charges' => wp_json_encode( $booking['charges'] ?? array() ), 'policy' => null === ( $booking['policy'] ?? null ) ? null : wp_json_encode( $booking['policy'] ), 'fields' => wp_json_encode( (object) ( $booking['fields'] ?? array() ) ), 'timezone' => (string) ( $booking['timezone'] ?? '' ), 'locale' => (string) ( $booking['locale'] ?? '' ), 'notes' => (string) ( $booking['notes'] ?? '' ), 'staff_notes' => (string) ( $booking['staff_notes'] ?? '' ), 'series' => (string) ( $booking['series'] ?? '' ), 'coupon' => (string) ( $booking['coupon'] ?? '' ), 'meeting_url' => mb_substr( (string) ( $booking['meeting_url'] ?? '' ), 0, 500 ), 'expires_at' => empty( $booking['expires_at'] ) ? null : self::dt( (int) $booking['expires_at'] ), 'created_at' => $now, 'updated_at' => $now, ) ); $id = (int) $this->db->insert_id; $this->insert_items( $id, $items, Status::holds_time( (string) $booking['status'] ) ); return $id; } /** * Insert items for a booking. * * @param int $booking_id Booking. * @param array> $items Items. * @param bool $active Whether they take time. */ private function insert_items( int $booking_id, array $items, bool $active ): void { foreach ( $items as $item ) { $this->db->insert( $this->items, array( 'booking_id' => $booking_id, 'bookable_id' => (int) $item['bookable_id'], 'session_id' => (int) ( $item['session_id'] ?? 0 ), 'staff_id' => (int) ( $item['staff_id'] ?? 0 ), 'location_id' => (int) ( $item['location_id'] ?? 0 ), 'resources' => implode( ',', array_map( 'intval', (array) ( $item['resources'] ?? array() ) ) ), 'start_at' => self::dt( (int) $item['start'] ), 'end_at' => self::dt( (int) $item['end'] ), 'block_start' => self::dt( (int) ( $item['block_start'] ?? $item['start'] ) ), 'block_end' => self::dt( (int) ( $item['block_end'] ?? $item['end'] ) ), 'quantity' => max( 1, (int) ( $item['quantity'] ?? 1 ) ), 'persons' => wp_json_encode( $item['persons'] ?? array() ), 'tickets' => wp_json_encode( $item['tickets'] ?? array() ), 'price_minor' => (int) ( $item['price'] ?? 0 ), 'active' => $active ? 1 : 0, ) ); } } /** * Replace a booking's items, e.g. when it is moved to another time. * * @param int $booking_id Booking. * @param array> $items New items. */ public function replace_items( int $booking_id, array $items ): void { $booking = $this->find( $booking_id ); $this->db->delete( $this->items, array( 'booking_id' => $booking_id ) ); $this->insert_items( $booking_id, $items, null !== $booking && Status::holds_time( $booking['status'] ) ); if ( array() !== $items ) { $this->db->update( $this->table, array( 'starts_at' => self::dt( (int) min( array_column( $items, 'start' ) ) ), 'ends_at' => self::dt( (int) max( array_column( $items, 'end' ) ) ), 'updated_at' => self::now(), ), array( 'id' => $booking_id ) ); } } public function find( int $id ): ?array { // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery $row = $this->db->get_row( $this->db->prepare( "SELECT * FROM {$this->table} WHERE id = %d", $id ), ARRAY_A ); return $row ? $this->with_items( array( $this->hydrate( $row ) ) )[0] : null; } public function find_by_uid( string $uid ): ?array { // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery $row = $this->db->get_row( $this->db->prepare( "SELECT * FROM {$this->table} WHERE uid = %s", strtoupper( $uid ) ), ARRAY_A ); return $row ? $this->with_items( array( $this->hydrate( $row ) ) )[0] : null; } /** * Bookings by ID, with items. * * @param int[] $ids IDs. * @return array> */ public function many( array $ids ): array { $ids = array_values( array_unique( array_filter( array_map( 'intval', $ids ) ) ) ); if ( array() === $ids ) { return array(); } // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.DirectDatabaseQuery $rows = (array) $this->db->get_results( $this->db->prepare( "SELECT * FROM {$this->table} WHERE id IN (" . self::in( $ids ) . ') ORDER BY starts_at', $ids ), ARRAY_A ); return $this->with_items( array_map( array( $this, 'hydrate' ), $rows ) ); } /** * Search bookings. * * @param array $filters status (list), from, to (Unix), staff_id, bookable_id, * location_id, customer_id, source, series, search, ids, * page, per_page, order (asc|desc), orderby (start|created). * @return array{items: array>, total: int} */ public function search( array $filters ): array { $where = array( '1=1' ); $args = array(); $join = ''; if ( ! empty( $filters['status'] ) ) { $status = array_values( array_intersect( (array) $filters['status'], Status::ALL ) ); $where[] = 'b.status IN (' . self::in( $status, '%s' ) . ')'; $args = array_merge( $args, array() !== $status ? $status : array( '' ) ); } if ( ! empty( $filters['from'] ) ) { $where[] = 'b.ends_at > %s'; $args[] = self::dt( (int) $filters['from'] ); } if ( ! empty( $filters['to'] ) ) { $where[] = 'b.starts_at < %s'; $args[] = self::dt( (int) $filters['to'] ); } foreach ( array( 'staff_id', 'bookable_id', 'location_id', 'session_id' ) as $column ) { if ( ! empty( $filters[ $column ] ) ) { $where[] = "EXISTS (SELECT 1 FROM {$this->items} f WHERE f.booking_id = b.id AND f.{$column} = %d)"; $args[] = (int) $filters[ $column ]; } } foreach ( array( 'customer_id' => '%d', 'source' => '%s', 'series' => '%s', ) as $column => $format ) { if ( isset( $filters[ $column ] ) && '' !== (string) $filters[ $column ] && 0 !== $filters[ $column ] ) { $where[] = "b.{$column} = {$format}"; $args[] = $filters[ $column ]; } } if ( ! empty( $filters['ids'] ) ) { $ids = array_map( 'intval', (array) $filters['ids'] ); $where[] = 'b.id IN (' . self::in( $ids ) . ')'; $args = array_merge( $args, $ids ); } if ( ! empty( $filters['search'] ) ) { $like = '%' . $this->db->esc_like( (string) $filters['search'] ) . '%'; $join = "LEFT JOIN {$this->db->prefix}schedulereed_customers c ON c.id = b.customer_id"; $where[] = '(b.uid LIKE %s OR c.email LIKE %s OR c.first_name LIKE %s OR c.last_name LIKE %s OR c.phone LIKE %s)'; array_push( $args, $like, $like, $like, $like, $like ); } $order = 'desc' === strtolower( (string) ( $filters['order'] ?? 'asc' ) ) ? 'DESC' : 'ASC'; $orderby = 'created' === ( $filters['orderby'] ?? '' ) ? 'b.created_at' : 'b.starts_at'; $per_page = max( 1, min( 500, (int) ( $filters['per_page'] ?? 50 ) ) ); $offset = max( 0, (int) ( $filters['page'] ?? 1 ) - 1 ) * $per_page; $sql = implode( ' AND ', $where ); // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.DirectDatabaseQuery, WordPress.DB.PreparedSQL.NotPrepared $count_sql = "SELECT COUNT(*) FROM {$this->table} b {$join} WHERE {$sql}"; $total = (int) $this->db->get_var( $args ? $this->db->prepare( $count_sql, $args ) : $count_sql ); $list_sql = "SELECT b.* FROM {$this->table} b {$join} WHERE {$sql} ORDER BY {$orderby} {$order}, b.id {$order} LIMIT %d OFFSET %d"; $rows = (array) $this->db->get_results( $this->db->prepare( $list_sql, array_merge( $args, array( $per_page, $offset ) ) ), ARRAY_A ); // phpcs:enable return array( 'items' => $this->with_items( array_map( array( $this, 'hydrate' ), $rows ) ), 'total' => $total, ); } /** * Change columns. * * @param int $id Booking. * @param array $data Hydrated names: status, total, deposit, charges, notes, ... */ public function update( int $id, array $data ): void { $map = array( 'status' => 'status', 'total' => 'total_minor', 'deposit' => 'deposit_minor', 'payment_method' => 'payment_method', 'notes' => 'notes', 'staff_notes' => 'staff_notes', 'customer_id' => 'customer_id', 'meeting_url' => 'meeting_url', 'rescheduled' => 'rescheduled', 'coupon' => 'coupon', 'locale' => 'locale', 'timezone' => 'timezone', ); $row = array(); foreach ( $map as $key => $column ) { if ( array_key_exists( $key, $data ) ) { $row[ $column ] = $data[ $key ]; } } foreach ( array( 'charges', 'policy', 'fields' ) as $json ) { if ( array_key_exists( $json, $data ) ) { $row[ $json ] = null === $data[ $json ] ? null : wp_json_encode( $data[ $json ] ); } } foreach ( array( 'expires_at', 'checked_in_at', 'cancelled_at' ) as $time ) { if ( array_key_exists( $time, $data ) ) { $row[ $time ] = empty( $data[ $time ] ) ? null : self::dt( (int) $data[ $time ] ); } } if ( array() === $row ) { return; } $row['updated_at'] = self::now(); $this->db->update( $this->table, $row, array( 'id' => $id ) ); if ( isset( $data['status'] ) ) { $this->db->update( $this->items, array( 'active' => Status::holds_time( (string) $data['status'] ) ? 1 : 0 ), array( 'booking_id' => $id ) ); } } /** * Keep the paid amount in step with the payments table. * * @param int $id Booking. * @param int $paid Minor units. */ public function set_paid( int $id, int $paid ): void { $this->db->update( $this->table, array( 'paid_minor' => $paid, 'updated_at' => self::now(), ), array( 'id' => $id ) ); } /** * Time taken by staff members between two moments. * * @param int[] $staff_ids Staff. * @param int $from Start. * @param int $to End. * @param int $except Booking to leave out, e.g. the one being moved. * @return array>> Staff ID => busy entries. */ public function busy_staff( array $staff_ids, int $from, int $to, int $except = 0 ): array { return $this->busy( 'staff_id', $staff_ids, $from, $to, $except ); } /** * Time a bookable's own capacity is used, for bookables with no staff or resources. * * @param int[] $bookable_ids Bookables. * @param int $from Start. * @param int $to End. * @param int $except Booking to leave out. * @return array>> */ public function busy_bookables( array $bookable_ids, int $from, int $to, int $except = 0 ): array { return $this->busy( 'bookable_id', $bookable_ids, $from, $to, $except ); } /** * Time taken on resources. * * @param int[] $resource_ids Resources. * @param int $from Start. * @param int $to End. * @param int $except Booking to leave out. * @return array>> Resource ID => busy entries. */ public function busy_resources( array $resource_ids, int $from, int $to, int $except = 0 ): array { $resource_ids = array_values( array_filter( array_map( 'intval', $resource_ids ) ) ); if ( array() === $resource_ids ) { return array(); } $find = array(); $args = array( self::dt( $to ), self::dt( $from ), $except, self::now() ); foreach ( $resource_ids as $id ) { $find[] = 'FIND_IN_SET(%d, i.resources)'; $args[] = $id; } // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.DirectDatabaseQuery $rows = (array) $this->db->get_results( $this->db->prepare( "SELECT i.*, b.status, b.uid FROM {$this->items} i JOIN {$this->table} b ON b.id = i.booking_id WHERE i.active = 1 AND i.block_start < %s AND i.block_end > %s AND i.booking_id <> %d AND (b.status <> 'awaiting_payment' OR b.expires_at IS NULL OR b.expires_at > %s) AND (" . implode( ' OR ', $find ) . ')', $args ), ARRAY_A ); $out = array_fill_keys( $resource_ids, array() ); foreach ( $rows as $row ) { foreach ( array_map( 'intval', explode( ',', (string) $row['resources'] ) ) as $id ) { if ( isset( $out[ $id ] ) ) { $out[ $id ][] = self::busy_entry( $row ); } } } return $out; } /** * Busy entries from items by a column. * * @param string $column staff_id or bookable_id. * @param int[] $ids Values. * @param int $from Start. * @param int $to End. * @param int $except Booking to leave out. * @return array>> */ private function busy( string $column, array $ids, int $from, int $to, int $except ): array { $ids = array_values( array_filter( array_map( 'intval', $ids ) ) ); if ( array() === $ids ) { return array(); } $args = array_merge( $ids, array( self::dt( $to ), self::dt( $from ), $except, self::now() ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.DirectDatabaseQuery $rows = (array) $this->db->get_results( $this->db->prepare( "SELECT i.*, b.status, b.uid FROM {$this->items} i JOIN {$this->table} b ON b.id = i.booking_id WHERE i.{$column} IN (" . self::in( $ids ) . ") AND i.active = 1 AND i.block_start < %s AND i.block_end > %s AND i.booking_id <> %d AND (b.status <> 'awaiting_payment' OR b.expires_at IS NULL OR b.expires_at > %s)", $args ), ARRAY_A ); $out = array_fill_keys( $ids, array() ); foreach ( $rows as $row ) { $out[ (int) $row[ $column ] ][] = self::busy_entry( $row ); } return $out; } /** * An item row as a slot engine busy entry. * * @param array $row Item row with booking status. * @return array */ private static function busy_entry( array $row ): array { return array( 'start' => self::ts( $row['block_start'] ), 'end' => self::ts( $row['block_end'] ), 'qty' => (int) $row['quantity'], 'kind' => 'booking', 'bookable_id' => (int) $row['bookable_id'], 'location_id' => (int) $row['location_id'], 'slot_start' => self::ts( $row['start_at'] ), 'session_id' => (int) $row['session_id'], 'label' => (string) $row['uid'], ); } /** * Places sold in sessions, in total and per ticket type. * * @param int[] $session_ids Sessions. * @param int $except Booking to leave out. * @return array}> */ public function sold( array $session_ids, int $except = 0 ): array { $session_ids = array_values( array_filter( array_map( 'intval', $session_ids ) ) ); if ( array() === $session_ids ) { return array(); } $args = array_merge( $session_ids, array( $except, self::now() ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.DirectDatabaseQuery $rows = (array) $this->db->get_results( $this->db->prepare( "SELECT i.session_id, i.quantity, i.tickets FROM {$this->items} i JOIN {$this->table} b ON b.id = i.booking_id WHERE i.session_id IN (" . self::in( $session_ids ) . ") AND i.active = 1 AND i.booking_id <> %d AND (b.status <> 'awaiting_payment' OR b.expires_at IS NULL OR b.expires_at > %s)", $args ), ARRAY_A ); $out = array(); foreach ( $session_ids as $id ) { $out[ $id ] = array( 'total' => 0, 'tickets' => array(), ); } foreach ( $rows as $row ) { $id = (int) $row['session_id']; $out[ $id ]['total'] += (int) $row['quantity']; foreach ( (array) self::json( $row['tickets'] ) as $ticket => $count ) { $out[ $id ]['tickets'][ (string) $ticket ] = ( $out[ $id ]['tickets'][ (string) $ticket ] ?? 0 ) + (int) $count; } } return $out; } /** * Unpaid online bookings whose time has run out. * * @param int $limit Most to return. * @return int[] */ public function expired_unpaid( int $limit = 100 ): array { // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery return array_map( 'intval', (array) $this->db->get_col( $this->db->prepare( "SELECT id FROM {$this->table} WHERE status = %s AND expires_at IS NOT NULL AND expires_at < %s ORDER BY id LIMIT %d", Status::AWAITING_PAYMENT, self::now(), $limit ) ) ); } /** * Bookings in some statuses starting in a window, e.g. for reminders. * * @param string[] $statuses Statuses. * @param int $from Earliest start. * @param int $to Latest start. * @return array> */ public function starting( array $statuses, int $from, int $to ): array { $args = array_merge( $statuses, array( self::dt( $from ), self::dt( $to ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.DirectDatabaseQuery $rows = (array) $this->db->get_results( $this->db->prepare( "SELECT * FROM {$this->table} WHERE status IN (" . self::in( $statuses, '%s' ) . ') AND starts_at >= %s AND starts_at < %s ORDER BY starts_at LIMIT 500', $args ), ARRAY_A ); return $this->with_items( array_map( array( $this, 'hydrate' ), $rows ) ); } /** * Bookings in some statuses that ended in a window, e.g. to complete or follow up. * * @param string[] $statuses Statuses. * @param int $from Earliest end. * @param int $to Latest end. * @return array> */ public function ended( array $statuses, int $from, int $to ): array { $args = array_merge( $statuses, array( self::dt( $from ), self::dt( $to ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.DirectDatabaseQuery $rows = (array) $this->db->get_results( $this->db->prepare( "SELECT * FROM {$this->table} WHERE status IN (" . self::in( $statuses, '%s' ) . ') AND ends_at >= %s AND ends_at < %s ORDER BY ends_at LIMIT 500', $args ), ARRAY_A ); return $this->with_items( array_map( array( $this, 'hydrate' ), $rows ) ); } /** * Count and value of bookings by status in a window of start times. * * @param int $from Start. * @param int $to End. * @return array */ public function totals( int $from, int $to ): array { // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery $rows = (array) $this->db->get_results( $this->db->prepare( "SELECT status, COUNT(*) AS n, SUM(total_minor) AS total, SUM(paid_minor) AS paid FROM {$this->table} WHERE starts_at >= %s AND starts_at < %s GROUP BY status", self::dt( $from ), self::dt( $to ) ), ARRAY_A ); $out = array(); foreach ( $rows as $row ) { $out[ (string) $row['status'] ] = array( 'count' => (int) $row['n'], 'total' => (int) $row['total'], 'paid' => (int) $row['paid'], ); } return $out; } /** * A customer's booking counts by status. * * @param int $customer_id Customer. * @return array */ public function customer_counts( int $customer_id ): array { // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery $rows = (array) $this->db->get_results( $this->db->prepare( "SELECT status, COUNT(*) AS n FROM {$this->table} WHERE customer_id = %d GROUP BY status", $customer_id ), ARRAY_A ); return array_column( array_map( static fn( array $r ): array => array( $r['status'], (int) $r['n'] ), $rows ), 1, 0 ); } /** * What a customer has paid in all. * * @param int $customer_id Customer. */ public function lifetime_value( int $customer_id ): int { // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery return (int) $this->db->get_var( $this->db->prepare( "SELECT COALESCE(SUM(paid_minor), 0) FROM {$this->table} WHERE customer_id = %d", $customer_id ) ); } /** * Move a customer's bookings to another customer, when two are merged. * * @param int $from Customer to empty. * @param int $to Customer to keep. */ public function reassign_customer( int $from, int $to ): void { $this->db->update( $this->table, array( 'customer_id' => $to ), array( 'customer_id' => $from ) ); } /** * Add items to bookings. * * @param array> $bookings Hydrated bookings. * @return array> */ private function with_items( array $bookings ): array { if ( array() === $bookings ) { return array(); } $ids = array_column( $bookings, 'id' ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare, WordPress.DB.DirectDatabaseQuery $rows = (array) $this->db->get_results( $this->db->prepare( "SELECT * FROM {$this->items} WHERE booking_id IN (" . self::in( $ids ) . ') ORDER BY start_at, id', $ids ), ARRAY_A ); $by = array(); foreach ( $rows as $row ) { $by[ (int) $row['booking_id'] ][] = array( 'id' => (int) $row['id'], 'bookable_id' => (int) $row['bookable_id'], 'session_id' => (int) $row['session_id'], 'staff_id' => (int) $row['staff_id'], 'location_id' => (int) $row['location_id'], 'resources' => '' === $row['resources'] ? array() : array_map( 'intval', explode( ',', (string) $row['resources'] ) ), 'start' => self::ts( $row['start_at'] ), 'end' => self::ts( $row['end_at'] ), 'block_start' => self::ts( $row['block_start'] ), 'block_end' => self::ts( $row['block_end'] ), 'quantity' => (int) $row['quantity'], 'persons' => (array) self::json( $row['persons'] ), 'tickets' => (array) self::json( $row['tickets'] ), 'price' => (int) $row['price_minor'], 'active' => (bool) $row['active'], ); } foreach ( $bookings as $i => $booking ) { $bookings[ $i ]['items'] = $by[ $booking['id'] ] ?? array(); } return $bookings; } /** * Cast a booking row. * * @param array $row Row. * @return array */ private function hydrate( array $row ): array { return array( 'id' => (int) $row['id'], 'uid' => (string) $row['uid'], 'token' => (string) $row['token'], 'customer_id' => (int) $row['customer_id'], 'status' => (string) $row['status'], 'source' => (string) $row['source'], 'start' => self::ts( $row['starts_at'] ), 'end' => self::ts( $row['ends_at'] ), 'total' => (int) $row['total_minor'], 'paid' => (int) $row['paid_minor'], 'deposit' => (int) $row['deposit_minor'], 'currency' => (string) $row['currency'], 'payment_method' => (string) $row['payment_method'], 'charges' => (array) self::json( $row['charges'] ), 'policy' => self::json( $row['policy'], null ), 'fields' => (array) self::json( $row['fields'] ), 'timezone' => (string) $row['timezone'], 'locale' => (string) $row['locale'], 'notes' => (string) $row['notes'], 'staff_notes' => (string) $row['staff_notes'], 'series' => (string) $row['series'], 'coupon' => (string) $row['coupon'], 'meeting_url' => (string) $row['meeting_url'], 'rescheduled' => (int) $row['rescheduled'], 'expires_at' => self::ts( $row['expires_at'] ), 'checked_in_at' => self::ts( $row['checked_in_at'] ), 'cancelled_at' => self::ts( $row['cancelled_at'] ), 'created_at' => self::ts( $row['created_at'] ), 'updated_at' => self::ts( $row['updated_at'] ), ); } }