コード例 #1
0
 /**
  * post Action for booking.
  *
  * @param AlterAppointmentRequest $request
  *
  * @return JSON Action result object
  */
 public function postAction(AlterAppointmentRequest $request)
 {
     logger()->info(__METHOD__);
     //////////////////
     // FOR REFACOTR //
     //////////////////
     $issuer = auth()->user();
     $businessId = $request->input('business');
     $appointment = Appointment::findOrFail($request->input('appointment'));
     $action = $request->input('action');
     $widgetType = $request->input('widget');
     ///////////////////////////////////
     // TODO: AUTHORIZATION GOES HERE //
     ///////////////////////////////////
     // AUTHORIZE:
     //  (A) auth()->user() is owner of $business
     // OR
     //  (B) auth()->user() is issuer of $appointment
     logger()->info(sprintf('postAction.request:[issuer:%s, action:%s, business:%s, appointment:%s]', $issuer->email, $action, $businessId, $appointment->id));
     try {
         $appointment = $this->concierge->requestAction(auth()->user(), $appointment, $action);
     } catch (\Exception $e) {
         return response()->json(['code' => 'ERROR', 'html' => '']);
     }
     $contents = ['appointment' => $appointment, 'user' => auth()->user()];
     $viewKey = "widgets.appointment.{$widgetType}._body";
     if (!view()->exists($viewKey)) {
         return response()->json(['code' => 'ERROR', 'html' => '']);
     }
     // Widgets MUST be rendered before being returned on Response as they need to be interpreted as HTML
     $html = view($viewKey, $contents)->render();
     logger()->info("postAction.response:[appointment:{$appointment->toJson()}]");
     return response()->json(['code' => 'OK', 'html' => $html]);
 }
コード例 #2
0
 /**
  * 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');
 }
コード例 #3
0
ファイル: WizardController.php プロジェクト: pra85/timegrid
 /**
  * get Dashboard page.
  *
  * @return Response Rendered view for Wizard
  */
 public function getDashboard(ConciergeService $concierge)
 {
     logger()->info(__METHOD__);
     $appointments = $concierge->getUnarchivedAppointmentsFor(auth()->user());
     $appointmentsCount = $appointments->count();
     $subscriptionsCount = auth()->user()->contacts->count();
     return view('user.dashboard', compact('appointments', 'appointmentsCount', 'subscriptionsCount'));
 }
コード例 #4
0
 /**
  * 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'));
 }
コード例 #5
0
 /**
  * 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'));
 }
コード例 #6
0
 /**
  * get Home
  *
  * @param  Business $business Business to display
  * @return Response           Rendered view for desired Business
  */
 public function getHome(Business $business)
 {
     $this->log->info(__METHOD__);
     $this->log->info(sprintf("  businessId:%s businessSlug:'%s'", $business->id, $business->slug));
     //////////////////
     // FOR REFACTOR //
     //////////////////
     $business_name = $business->name;
     Notifynder::category('user.visitedShowroom')->from('App\\Models\\User', auth()->user()->id)->to('App\\Models\\Business', $business->id)->url('http://localhost')->extra(compact('business_name'))->send();
     $concierge = new ConciergeService(new VacancyService($business));
     $available = $concierge->isAvailable(auth()->user());
     return view('user.businesses.show', compact('business', 'available'));
 }
コード例 #7
0
 /**
  * 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'));
 }
コード例 #8
0
ファイル: WizardController.php プロジェクト: kdh4242/timegrid
 /**
  * get Dashboard page.
  *
  * @return Response Rendered view for Wizard
  */
 public function getDashboard(ConciergeService $concierge)
 {
     logger()->info(__METHOD__);
     $appointments = $concierge->getUnarchivedAppointmentsFor(auth()->user());
     return view('user.dashboard', ['appointments' => $appointments]);
 }