<?php
/**
 * Journey Event Query Class.
 *
 * @package     EDD\Pro\CartRecovery\Database\Queries
 * @copyright   Copyright (c) 2026, Sandhills Development, LLC
 * @license     https://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       3.6.5
 */

namespace EDD\Pro\CartRecovery\Database\Queries;

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

use EDD\Database\Query;

/**
 * Class used for querying journey events.
 *
 * @since 3.6.5
 *
 * @see \EDD\Pro\CartRecovery\Database\Queries\JourneyEvent::__construct() for accepted arguments.
 */
class JourneyEvent extends Query {

	/** Table Properties ******************************************************/

	/**
	 * Name of the database table to query.
	 *
	 * @var string
	 */
	protected $table_name = 'acr_journey_events';

	/**
	 * String used to alias the database table in MySQL statement.
	 *
	 * @var string
	 */
	protected $table_alias = 'je';

	/**
	 * Name of class used to setup the database schema
	 *
	 * @var string
	 */
	protected $table_schema = '\\EDD\\Pro\\CartRecovery\\Database\\Schemas\\JourneyEvents';

	/** Item ******************************************************************/

	/**
	 * Name for a single item
	 *
	 * @var string
	 */
	protected $item_name = 'journey_event';

	/**
	 * Plural version for a group of items.
	 *
	 * @var string
	 */
	protected $item_name_plural = 'journey_events';

	/**
	 * Callback function for turning IDs into objects
	 *
	 * @var mixed
	 */
	protected $item_shape = '\\EDD\\Pro\\CartRecovery\\Database\\Rows\\JourneyEvent';

	/** Cache *****************************************************************/

	/**
	 * Group to cache queries and queried items in.
	 *
	 * @var string
	 */
	protected $cache_group = 'acr_journey_events';

	/**
	 * Override default ordering to favour chronological order.
	 *
	 * @since 3.6.5
	 */
	protected function set_query_var_defaults() {
		parent::set_query_var_defaults();

		$this->query_var_defaults['orderby'] = 'date_created';
		$this->query_var_defaults['order']   = 'ASC';
	}
}
