*/ public const VALID_KINDS = [ self::KIND_PRIVATE_LESSON, self::KIND_GROUP_CLASS ]; public const BILLING_ONE_TIME = 'one_time'; public const BILLING_FULL_TERM = 'full_term'; /** * All valid billing modes. * * @var list */ public const VALID_BILLING_MODES = [ self::BILLING_ONE_TIME, self::BILLING_FULL_TERM ]; public function __construct( public readonly int $instructorId, public readonly string $kind, public readonly string $title, public readonly int $priceCents = 0, public readonly string $currency = 'CAD', public readonly string $billingMode = self::BILLING_ONE_TIME, public readonly ?string $description = null, public readonly ?int $durationMinutes = null, public readonly bool $allowWeekly = false, public readonly ?int $capacity = null, public readonly ?string $termStart = null, public readonly ?string $termEnd = null, public readonly ?string $scheduleNote = null, public readonly bool $isActive = true, public readonly ?int $id = null, ) {} public static function fromRow( object $row ): self { return new self( instructorId: (int) $row->instructor_id, kind: $row->kind, title: $row->title, priceCents: (int) $row->price_cents, currency: $row->currency, billingMode: $row->billing_mode, description: $row->description, durationMinutes: null !== $row->duration_minutes ? (int) $row->duration_minutes : null, allowWeekly: (bool) $row->allow_weekly, capacity: null !== $row->capacity ? (int) $row->capacity : null, termStart: $row->term_start, termEnd: $row->term_end, scheduleNote: $row->schedule_note, isActive: (bool) $row->is_active, id: (int) $row->id, ); } /** * Returns a plain array representation of the offering. * * @return array */ public function toArray(): array { return [ 'id' => $this->id, 'instructor_id' => $this->instructorId, 'kind' => $this->kind, 'title' => $this->title, 'description' => $this->description, 'duration_minutes' => $this->durationMinutes, 'price_cents' => $this->priceCents, 'currency' => $this->currency, 'billing_mode' => $this->billingMode, 'allow_weekly' => $this->allowWeekly, 'capacity' => $this->capacity, 'term_start' => $this->termStart, 'term_end' => $this->termEnd, 'schedule_note' => $this->scheduleNote, 'is_active' => $this->isActive, ]; } }