Occurrence::is_last( int|TECEventsCustom_TablesV1ModelsOccurrence $occurrence )

Returns whether an Occurrence is the last Occurrence in context of the Recurring Event it belongs to, or not.


Parameters

$occurrence

(int|TECEventsCustom_TablesV1ModelsOccurrence) (Required) Either an Occurrence occurrence_id or an instance of the Occurrence Model.


Top ↑

Return

(bool) Whether an Occurrence is the first occurrence in context of the Recurring Event it belongs to, or not.


Top ↑

Source

File: src/Events/Custom_Tables/V1/Models/Occurrence.php

	public static function is_last( $occurrence ) {
		$occurrence = $occurrence instanceof self
			? $occurrence
			: static::find( $occurrence, 'occurrence_id' );

		if ( ! $occurrence instanceof self ) {
			return false;
		}

		$last = self::where( 'event_id', '=', $occurrence->event_id )
		            ->order_by( 'start_date', 'DESC' )
		            ->first();

		return $last instanceof self
		       && $last->occurrence_id === $occurrence->occurrence_id;
	}

Top ↑

Changelog

Changelog
Version Description
6.0.0 Introduced.