protected function updateTimeslots(Vacancy $vacancy)
 {
     $fromTime = $vacancy->start_at;
     $toTime = $vacancy->finish_at;
     $capacity = $vacancy->getAvailableCapacityBetween($fromTime->timezone('UTC'), $toTime->timezone('UTC'));
     $time = $fromTime->timezone($vacancy->business->timezone)->format('H:i:s');
     $this->timetable->capacity($vacancy->date, $time, $vacancy->service->slug, $capacity);
 }
 protected function updateTimeslots(Vacancy $vacancy, $step = 30)
 {
     $fromTime = $vacancy->start_at->timezone('UTC');
     $toTime = $fromTime->copy();
     $limit = $vacancy->finish_at;
     while ($fromTime <= $limit) {
         $toTime->addMinutes($step);
         $capacity = $vacancy->getAvailableCapacityBetween($fromTime, $toTime);
         $time = $fromTime->timezone($vacancy->business->timezone)->format('H:i:s');
         $this->timetable->capacity($vacancy->date, $time, $vacancy->service->slug, $capacity);
         $fromTime->addMinutes($step);
     }
 }
Esempio n. 3
0
 /**
  * @covers  Timegridio\Concierge\Models\Vacancy::scopeFuture
  * @test
  */
 public function it_scopes_future()
 {
     $this->arrangeFixture();
     $this->vacancy = $this->createVacancy(['business_id' => $this->business->id, 'date' => Carbon::parse('tomorrow')->toDateString(), 'start_at' => Carbon::parse('tomorrow')]);
     $this->vacancy = $this->createVacancy(['business_id' => $this->business->id, 'date' => Carbon::parse('tomorrow +1 day')->toDateString(), 'start_at' => Carbon::parse('tomorrow +1 day')]);
     $vacancies = Vacancy::future()->get();
     /* Perform Test */
     $this->assertCount(2, $vacancies);
 }
Esempio n. 4
0
 public function publish($date, Carbon $startAt, Carbon $finishAt, $serviceId, $capacity = 1)
 {
     $vacancyKeys = ['business_id' => $this->business->id, 'service_id' => $serviceId, 'date' => $date];
     $vacancyValues = ['capacity' => intval($capacity), 'start_at' => $startAt->timezone('UTC')->toDateTimeString(), 'finish_at' => $finishAt->timezone('UTC')->toDateTimeString()];
     return Vacancy::updateOrCreate($vacancyKeys, $vacancyValues);
 }