/** * post Store. * * @param Request $request Input data of booking form * * @return Response Redirect to Appointments listing */ public function postStore(Request $request) { $this->log->info(__METHOD__); ////////////////// // FOR REFACTOR // ////////////////// $issuer = auth()->user(); $business = Business::findOrFail($request->input('businessId')); $contact = $issuer->getContactSubscribedTo($business->id); $service = Service::find($request->input('service_id')); $strDateTime = $request->input('_date') . ' ' . $business->pref('start_at'); $datetime = Carbon::parse($strDateTime . ' ' . $business->timezone)->setTimezone('UTC'); $comments = $request->input('comments'); $this->concierge->setBusiness($business); $appointment = $this->concierge->makeReservation($issuer, $business, $contact, $service, $datetime, $comments); if (false === $appointment) { $this->log->info('[ADVICE] Unable to book'); Flash::warning(trans('user.booking.msg.store.error')); return redirect()->route('user.agenda'); } if (!$appointment->exists) { $this->log->info('[ADVICE] Appointment is duplicated'); Flash::warning(trans('user.booking.msg.store.sorry_duplicated', ['code' => $appointment->code])); return redirect()->route('user.agenda'); } $this->log->info('Appointment saved successfully'); event(new NewBooking($issuer, $appointment)); Flash::success(trans('user.booking.msg.store.success', ['code' => $appointment->code])); return redirect()->route('user.agenda'); }
/** * get Index. * * @param Business $business Business to get agenda * * @return Response Rendered view of Business agenda */ public function getIndex(Business $business) { logger()->info(__METHOD__); logger()->info(sprintf('businessId:%s', $business->id)); $this->authorize('manage', $business); $appointments = $this->concierge->setBusiness($business)->getUnservedAppointments(); $viewKey = 'manager.businesses.appointments.' . $business->strategy . '.index'; return view($viewKey, compact('business', 'appointments')); }
/** * send Business Report. * * @param Business $business * * @return void */ protected function sendBusinessReport(Business $business) { $this->info(__METHOD__); $this->info("Sending to businessId:{$business->id}"); $appointments = $this->concierge->setBusiness($business)->getActiveAppointments(); $owner = $business->owners()->first(); // Mail to User $header = ['email' => $owner->email, 'name' => $owner->name]; $this->transmail->locale($business->locale)->template('appointments.manager._schedule')->subject('manager.business.report.subject', ['date' => date('Y-m-d'), 'business' => $business->name])->send($header, compact('business', 'appointments')); }
/** * get Home. * * @param Business $business Business to display * * @return Response Rendered view for desired Business */ public function getHome(Business $business) { logger()->info(__METHOD__); logger()->info(sprintf("businessId:%s businessSlug:'%s'", $business->id, $business->slug)); $businessName = $business->name; Notifynder::category('user.visitedShowroom')->from('App\\Models\\User', auth()->user()->id)->to('App\\Models\\Business', $business->id)->url('http://localhost')->extra(compact('businessName'))->send(); $concierge = new ConciergeService(new VacancyService()); $concierge->setBusiness($business); $available = $concierge->isAvailable(auth()->user()); $appointment = $concierge->getNextAppointmentFor(auth()->user()->contacts); return view('user.businesses.show', compact('business', 'available', 'appointment')); }