public function getTemplate(Business $business, Service $service) { $this->addServiceStatement($service); $this->addDaysStatement(); $this->addTimeRangeStatement($business->pref('start_at'), $business->pref('finish_at')); return $this->build(); }
protected function setBusinessPreferences(Business $business, $preferences) { // Get parameters from app configuration $parameters = config()->get('preferences.Timegridio\\Concierge\\Models\\Business'); // Get the keys of the parameters $parametersKeys = array_flip(array_keys($parameters)); // Merge the user input with the parameter keys $mergedPreferences = array_intersect_key($preferences, $parametersKeys); // Store each parameter key-value pair to the business preferences foreach ($mergedPreferences as $key => $value) { logger()->info(sprintf("set preference: businessId:%s key:%s='%s' type:%s", $business->id, $key, $value, $parameters[$key]['type'])); $business->pref($key, $value, $parameters[$key]['type']); } }
private function getContacts($expression) { $businesses = Business::whereIn('id', $this->scope['businessesIds'])->get(); foreach ($businesses as $business) { $collection = $business->contacts()->where(function ($query) use($expression) { $query->where('lastname', 'like', $expression . '%')->orWhere('firstname', 'like', $expression . '%')->orWhere('nin', $expression)->orWhere('mobile', 'like', '%' . $expression); })->get(); $this->results['contacts'] = $collection; } }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * * @return void */ public function boot(Router $router) { // parent::boot($router); $router->model('contact', Contact::class); $router->model('service', Service::class); $router->model('appointment', Appointment::class); $router->bind('business', function ($businessSlug) { return Business::where('slug', $businessSlug)->first(); }); }
/** * get Home. * * @param Business $business Business to display * * @return Response Rendered view for desired Business */ public function getHome($slug) { logger()->info(__METHOD__); logger()->info(sprintf('slug:%s', $slug)); if ($domain = Domain::where('slug', $slug)->first()) { return $this->getDomain($domain); } if ($business = Business::where('slug', $slug)->first()) { session()->set('guest.last-intended-business-home', $slug); return view('guest.businesses.show', compact('business')); } session()->forget('guest.last-intended-business-home'); $baseurl = url()->to('/' . $slug); flash()->success(trans('app.msg.slug_is_available', compact('baseurl'))); return redirect()->to('/auth/login'); }
protected function calculateStep(Business $business, $defaultStep = 30) { $step = $business->pref('timeslot_step'); if (0 != $step) { return $step; } return $defaultStep; }
protected function autopublishVacancies(Business $business) { return $business->pref('vacancy_autopublish'); }
private function putUserGuestContactOf(Contact $contact, Business $business) { $business->contacts()->save($contact); }
protected function enabledReports(Business $business) { return $business->pref('report_daily_schedule'); }
/** * show Contact. * * @param Business $business Business holding the Contact * @param Contact $contact Desired Contact to show * * @return Response Rendered view of Contact */ public function show(Business $business, Contact $contact) { logger()->info(__METHOD__); logger()->info(sprintf('businessId:%s contactId:%s', $business->id, $contact->id)); $this->authorize('manage', $contact); // BEGIN $memberSince = $business->contacts()->find($contact->id)->pivot->created_at; $appointments = $contact->appointments()->orderBy('start_at')->ofBusiness($business->id)->active()->get(); return view('user.contacts.show', compact('business', 'contact', 'appointments', 'memberSince')); }
/** * 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); }
/** * Update notes from pivot table. * * @param Business $business * @param Contact $contact * @param string $notes * * @return void */ protected function updateNotes(Business $business, Contact $contact, $notes = null) { if ($notes) { $business->contacts()->find($contact->id)->pivot->update(['notes' => $notes]); } }
/** * get List. * * @return Response Rendered view of all existing Businesses */ public function getList() { logger()->info(__METHOD__); $businesses = Business::all(); return view('user.businesses.index', compact('businesses')); }
protected function arrangeBusinessWithOwner() { $this->owner = $this->createUser(); $this->business = $this->createBusiness(); $this->business->owners()->save($this->owner); }
/** * Set category to a Business and save. * * @param Business $business * @param int $category * * @return Timegridio\Concierge\Models\Business */ public function setCategory(Business $business, $category) { $category = Category::find($category); $business->category()->associate($category); $business->save(); return $business; }
public function getBusiness($id, $identificator = null) { $identificator = $identificator ?: $this->identificator; return Business::where($identificator, $id)->first(); }