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.
Contents
Parameters
- $occurrence
-
(int|TECEventsCustom_TablesV1ModelsOccurrence) (Required) Either an Occurrence
occurrence_idor an instance of the Occurrence Model.
Return
(bool) Whether an Occurrence is the first occurrence in context of the Recurring Event it belongs to, or not.
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;
}
Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |