Пример #1
0
 /**
  * make Reservation
  * @param  User     $issuer   Requested by User as issuer
  * @param  Business $business For Business
  * @param  Contact  $contact  On behalf of Contact
  * @param  Service  $service  For Service
  * @param  Carbon   $datetime     for Date and Time
  * @param  string   $comments     optional issuer comments for the appointment
  * @return Appointment|boolean             Generated Appointment or false
  */
 public function makeReservation(User $issuer, Business $business, Contact $contact, Service $service, Carbon $datetime, $comments = null)
 {
     $bookingStrategy = new BookingStrategy($business->strategy);
     $appointment = $bookingStrategy->generateAppointment($issuer, $business, $contact, $service, $datetime, $comments);
     if ($appointment->duplicates()) {
         return $appointment;
     }
     $availability = new AvailabilityServiceLayer($business);
     $vacancy = $availability->getSlotFor($appointment);
     if (null !== $vacancy) {
         if ($vacancy->hasRoom()) {
             $appointment->vacancy()->associate($vacancy);
             $appointment->save();
             return $appointment;
         }
     }
     return false;
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Business $business)
 {
     $this->log->info("BusinessServiceController: create: businessId:{$business->id}");
     $dates = AvailabilityServiceLayer::generateAvailability($business->vacancies);
     $services = $business->services;
     if ($services->isEmpty()) {
         return view('manager.businesses.vacancies.edit', compact('business', 'dates', 'services'))->withErrors(array("msg" => trans('manager.vacancies.msg.edit.no_services')));
     }
     return view('manager.businesses.vacancies.edit', compact('business', 'dates', 'services'));
 }