/** * post Store * * @param Request $request Input data of booking form * @param ConciergeServiceLayer $concierge Concierge injection * @return Response Redirect to Appointments listing */ public function postStore(Request $request, ConciergeServiceLayer $concierge) { $this->log->info('AgendaController: postStore'); $issuer = auth()->user(); $business = Business::findOrFail($request->input('businessId')); $contact = $issuer->getContactSubscribedTo($business); $service = Service::find($request->input('service_id')); $datetime = Carbon::parse($request->input('_date') . ' ' . $business->pref('start_at'))->timezone($business->timezone); $comments = $request->input('comments'); $appointment = $concierge->makeReservation($issuer, $business, $contact, $service, $datetime, $comments); if (false === $appointment) { $this->log->info('AgendaController: postStore: [ADVICE] Unable to book '); Flash::warning(trans('user.booking.msg.store.error')); return redirect()->route('user.booking.list'); } $appointmentPresenter = $appointment->getPresenter(); if ($appointment->exists) { $this->log->info('AgendaController: postStore: Appointment saved successfully '); Event::fire(new NewBooking($issuer, $appointment)); Flash::success(trans('user.booking.msg.store.success', ['code' => $appointmentPresenter->code()])); } else { $this->log->info('AgendaController: postStore: [ADVICE] Appointment is duplicated '); Flash::warning(trans('user.booking.msg.store.sorry_duplicated', ['code' => $appointmentPresenter->code()])); } return redirect()->route('user.booking.list'); }
/** * get Home * * @param Business $business Business to display * @return Response Rendered view for desired Business */ public function getHome(Business $business) { $this->log->info("BusinessController: getHome: businessId:{$business->id} businessSlug:({$business->slug})"); $business_name = $business->name; Notifynder::category('user.visitedShowroom')->from('App\\User', auth()->user()->id)->to('App\\Business', $business->id)->url('http://localhost')->extra(compact('business_name'))->send(); $concierge = new ConciergeServiceLayer(); $available = $concierge->isAvailable($business, auth()->user()); # $available = true; /* ToDo */ return view('user.businesses.show', compact('business', 'available')); }
/** * Test Attempt Bad Reservation * @covers \App\ConciergeServiceLayer::makeReservation */ public function testAttemptBadReservation() { /* Setup Stubs */ $issuer = factory(User::class)->create(); $business = factory(Business::class)->create(); $business->owners()->save($issuer); $service = factory(Service::class)->make(); $business->services()->save($service); $vacancy = factory(Vacancy::class)->make(); $vacancy->service()->associate($service); $business->vacancies()->save($vacancy); $contact = factory(Contact::class)->create(); $business->contacts()->save($contact); /* Perform Test */ $concierge = new ConciergeServiceLayer(); #$date = Carbon::parse(date('Y-m-d H:i:s', strtotime($vacancy->date .' '. $business->pref('start_at') . ' +1 day')), $business->timezone)->timezone('UTC'); $date = Carbon::parse(date('Y-m-d H:i:s', strtotime($vacancy->date . ' ' . $business->pref('start_at') . ' +1 day')), $business->timezone); $appointment = $concierge->makeReservation($issuer, $business, $contact, $service, $date); $this->assertFalse($appointment); }