public function transformArray($rows)
 {
     $result = [];
     foreach ($rows as $o) {
         // process occurrence
         if ($this->newOccurrence($o)) {
             if ($this->currentOccurrence) {
                 $result[] = $this->currentOccurrence;
             }
             $signupDeadline = new Carbon($o->signup_deadline);
             // keep this logic in the helper
             // it's also used in the OpportunityOccurrence model
             $closed = npmso_is_registration_closed('sponsorship' == $o->type, $o->slots_available, $o->sponsorships_available, $o->min_participants_per_registration, $signupDeadline);
             $this->currentOccurrence = ['name' => trim($o->name), 'description' => trim($o->description), 'warningText' => $o->warning_text, 'childrenRules' => $o->children_rules, 'type' => $o->type, 'beneficiaryUid' => $o->beneficiary_uid, 'beneficiary' => $o->beneficiary, 'beneficiaryDescription' => $o->beneficiary_description, 'beneficiaryUrl' => $o->beneficiary_url, 'collectParticipantInfo' => $this->bool($o->collect_participant_info), 'showLocation' => $this->bool($o->show_location), 'locationName' => $o->location_name, 'sponsorshipLabel' => $o->sponsorship_label, 'uid' => $o->uid, 'date' => $this->formatDate(new Carbon($o->occurrence_date)), 'occ_date' => $o->occurrence_date, 'sponsorship_end_date' => $this->formatDate(new Carbon($o->sponsorship_end_date)), 'time' => $this->formatTimeRange(new Carbon($o->start_time), new Carbon($o->end_time)), 'open' => !$this->bool($closed), 'minParticipants' => (int) $o->min_participants_per_registration, 'signupDeadline' => $this->formatDate($signupDeadline), 'slotsAvailable' => (int) $o->slots_available, 'sponsorshipsAvailable' => (int) $o->sponsorships_available, 'availability' => 'sponsorship' == $o->type ? (int) $o->sponsorships_available : (int) $o->slots_available, 'capacity' => (int) $o->capacity, 'timeOfDay' => $o->time_of_day, 'dayOfWeek' => $o->day_of_week, 'early_access' => $o->early_access, 'filterAttributes' => [], 'filterAttributeNames' => []];
         }
         // process attribute
         if ($o->value_uid && $o->attribute_value) {
             $this->currentOccurrence['filterAttributes'][$o->attribute_uid] = $o->value_uid;
             $this->currentOccurrence['filterAttributeNames'][$o->attribute_name] = $o->attribute_value;
         }
     }
     if ($this->currentOccurrence) {
         $result[] = $this->currentOccurrence;
         // last one
     }
     return $result;
 }
 public function testIsRegistrationClosedSponsorshipDate()
 {
     // arrange
     $isSponsorship = false;
     $remainingSlots = null;
     $remainingSponsorships = 1;
     $minSlotsPerReg = null;
     $endDate = new Carbon('1982-07-09');
     // act
     $closed = npmso_is_registration_closed($isSponsorship, $remainingSlots, $remainingSponsorships, $minSlotsPerReg, $endDate);
     // assert
     $this->assertTrue($closed);
 }
 public function getClosedAttribute()
 {
     // keep this logic in the helper, not the model
     // it's also used by OccurrenceQueryTransformer
     return npmso_is_registration_closed($this->isSponsorship(), $this->slotsAvailable, $this->sponsorshipsAvailable, $this->min_participants_per_registration, $this->signup_deadline);
 }