Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $businessId = $this->argument('business');
     if ($businessId === null) {
         $this->info('Scanning all businesses...');
         $this->scanBusinesses();
     } else {
         $this->info("Sending to specified businessId:{$businessId}");
         $business = Business::findOrFail($businessId);
         $this->sendBusinessReport($business);
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $businessId = $this->argument('business');
     if ($businessId === null) {
         $this->info('Scanning all businesses...');
         $this->scanBusinesses();
     } else {
         $this->info("Publishing for specified businessId:{$businessId}");
         $business = Business::findOrFail($businessId);
         $this->publishVacancies($business);
     }
 }
Ejemplo n.º 3
0
 /**
  * Get available times.
  *
  * @param int    $businessId
  * @param int    $serviceId
  * @param string $date
  *
  * @return Symfony\Component\HttpFoundation\JsonResponse
  */
 public function getTimes($businessId, $serviceId, $date, $timezone = false)
 {
     logger()->info(__METHOD__);
     logger()->info("businessId:{$businessId} serviceId:{$serviceId} date:{$date}");
     $business = Business::findOrFail($businessId);
     $service = $business->services()->findOrFail($serviceId);
     $vacancies = $business->vacancies()->forService($serviceId)->forDate(Carbon::parse($date))->get();
     if (!$timezone) {
         $timezone = auth()->user()->pref('timezone');
         logger()->info('User Timezone Preference: ' . $timezone);
     }
     $times = $this->splitTimes($vacancies, $service, $timezone);
     return response()->json(['business' => $businessId, 'service' => ['id' => $service->id, 'duration' => $service->duration], 'date' => $date, 'times' => $times, 'timezone' => $timezone], 200);
 }
Ejemplo n.º 4
0
 /**
  * post Store.
  *
  * @param Request $request Input data of booking form
  *
  * @return Response Redirect to Appointments listing
  */
 public function postStore(Request $request)
 {
     logger()->info(__METHOD__);
     //////////////////
     // FOR REFACTOR //
     //////////////////
     $business = Business::findOrFail($request->input('businessId'));
     $issuer = auth()->user();
     $isOwner = $issuer->isOwner($business->id);
     if ($request->input('contact_id') && $isOwner) {
         $contact = $business->contacts()->find($request->input('contact_id'));
     } else {
         $contact = $issuer->getContactSubscribedTo($business->id);
     }
     // Authorize contact is subscribed to Business
     // ...
     $service = $business->services()->find($request->input('service_id'));
     $date = Carbon::parse($request->input('_date'))->toDateString();
     $time = Carbon::parse($request->input('_time'))->toTimeString();
     $timezone = $request->input('_timezone') ?: $business->timezone;
     $comments = $request->input('comments');
     $reservation = ['issuer' => $issuer->id, 'contact' => $contact, 'service' => $service, 'date' => $date, 'time' => $time, 'timezone' => $timezone, 'comments' => $comments];
     logger()->info('issuer:' . $issuer->id);
     logger()->info('business:' . $business->id);
     logger()->info('contact:' . $contact->id);
     logger()->info('service:' . $service->id);
     logger()->info('date:' . $date);
     logger()->info('time:' . $time);
     logger()->info('timezone:' . $timezone);
     try {
         $appointment = $this->concierge->business($business)->takeReservation($reservation);
     } catch (DuplicatedAppointmentException $e) {
         $code = $this->concierge->appointment()->code;
         logger()->info('DUPLICATED Appointment with CODE:' . $code);
         flash()->warning(trans('user.booking.msg.store.sorry_duplicated', ['code' => $code]));
         if ($isOwner) {
             return redirect()->route('manager.business.agenda.index', compact('business'));
         }
         return redirect()->route('user.agenda');
     }
     if (false === $appointment) {
         logger()->info('[ADVICE] Unable to book');
         flash()->warning(trans('user.booking.msg.store.error'));
         return redirect()->back();
     }
     logger()->info('Appointment saved successfully');
     event(new NewAppointmentWasBooked($issuer, $appointment));
     flash()->success(trans('user.booking.msg.store.success', ['code' => $appointment->code]));
     if ($isOwner) {
         return redirect()->route('manager.business.agenda.index', compact('business'));
     }
     return redirect()->route('user.agenda', '#' . $appointment->code);
 }