/** * 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')); }
/** * get Home. * * @param Business $business Business to display * * @return Response Rendered view for desired Business */ public function getHome(Business $business, Concierge $concierge) { 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('Timegridio\\Concierge\\Models\\Business', $business->id)->url('http://localhost')->extra(compact('businessName'))->send(); $available = $concierge->business($business)->isBookable('today', 30); $appointment = $business->bookings()->forContacts(auth()->user()->contacts)->active()->first(); return view('user.businesses.show', compact('business', 'available', 'appointment')); }
/** * 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')); }
/** * 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')); }
/** * Handle the event. * * @param AppointmentWasConfirmed $event * * @return void */ public function handle(AppointmentWasCanceled $event) { logger()->info(__METHOD__); $code = $event->appointment->code; $date = $event->appointment->start_at->toDateString(); $businessName = $event->appointment->business->name; Notifynder::category('appointment.cancel')->from('App\\Models\\User', $event->user->id)->to('Timegridio\\Concierge\\Models\\Business', $event->appointment->business->id)->url('http://localhost')->extra(compact('businessName', 'code', 'date'))->send(); ///////////////// // Send emails // ///////////////// // Mail to User $params = ['user' => $event->user, 'appointment' => $event->appointment]; $header = ['name' => $event->appointment->contact->firstname, 'email' => $event->appointment->contact->email]; $this->transmail->locale($event->appointment->business->locale)->template('appointments.user._canceled')->subject('user.appointment.canceled.subject', ['business' => $event->appointment->business->name])->send($header, $params); }
/** * post Preferences. * * @param Business $business Business to update preferences * @param Request $request * * @return Response Redirect */ public function postPreferences(Business $business, Request $request) { $this->log->info(__METHOD__); $this->log->info(sprintf('businessId:%s', $business->id)); $this->authorize('managePreferences', $business); // BEGIN ////////////////// // FOR REFACTOR // ////////////////// $this->setBusinessPreferences($business, $request->all()); $businessName = $business->name; Notifynder::category('user.updatedBusinessPreferences')->from('App\\Models\\User', auth()->user()->id)->to('App\\Models\\Business', $business->id)->url('http://localhost')->extra(compact('businessName'))->send(); Flash::success(trans('manager.businesses.msg.preferences.success')); return redirect()->route('manager.business.show', $business); }
/** * Handle the event. * * @param NewBooking $event * @return void */ public function handle(NewBooking $event) { logger()->info('Handle NewBooking.SendBookingNotification()'); $code = $event->appointment->getPresenter()->code(); $date = $event->appointment->start_at->toDateString(); $business_name = $event->appointment->business->name; Notifynder::category('appointment.reserve')->from('App\\User', $event->user->id)->to('App\\Business', $event->appointment->business->id)->url('http://localhost')->extra(compact('business_name', 'code', 'date'))->send(); $locale = app()->getLocale(); Mail::send("emails.{$locale}.appointments.user._new", ['user' => $event->user, 'appointment' => $event->appointment->getPresenter()], function ($m) use($event) { $m->to($event->user->email, $event->user->name)->subject(trans('emails.user.appointment.reserved.subject')); }); Mail::send("emails.{$locale}.appointments.manager._new", ['user' => $event->appointment->business->owner(), 'appointment' => $event->appointment->getPresenter()], function ($m) use($event) { $m->to($event->appointment->business->owner()->email, $event->appointment->business->owner()->name)->subject(trans('emails.manager.appointment.reserved.subject')); }); }
/** * store Business. * * @param BusinessFormRequest $request Business form Request * * @return Response Redirect */ public function store(BusinessFormRequest $request) { $this->log->info(__METHOD__); // BEGIN try { $business = $this->businessService->register(auth()->user(), $request->all(), $request->get('category')); } catch (BusinessAlreadyRegisteredException $exception) { Flash::error(trans('manager.businesses.msg.store.business_already_exists')); return redirect()->back()->withInput(request()->all()); } // Generate local notification $businessName = $business->name; Notifynder::category('user.registeredBusiness')->from('App\\Models\\User', auth()->user()->id)->to('App\\Models\\Business', $business->id)->url('http://localhost')->extra(compact('businessName'))->send(); // Redirect success Flash::success(trans('manager.businesses.msg.store.success')); return redirect()->route('manager.business.service.create', $business); }
/** * post Preferences * * @param Business $business Business to update preferences * @return Response Redirect */ public function postPreferences(Business $business, Request $request) { $this->log->info("Manager\\BusinessController: postPreferences: businessId:{$business->id}"); if (Gate::denies('managePreferences', $business)) { abort(403); } $parameters = config()->get('preferences.App\\Business'); $parametersKeys = array_flip(array_keys($parameters)); $preferences = $request->all(); $preferences = array_intersect_key($preferences, $parametersKeys); foreach ($preferences as $key => $value) { $this->log->info("Manager\\BusinessController: " . "postPreferences: businessId:{$business->id} key:{$key} value:{$value} " . "type:{$parameters[$key]['type']}"); $business->pref($key, $value, $parameters[$key]['type']); } $business_name = $business->name; Notifynder::category('user.updatedBusinessPreferences')->from('App\\User', auth()->user()->id)->to('App\\Business', $business->id)->url('http://localhost')->extra(compact('business_name'))->send(); Flash::success(trans('manager.businesses.msg.preferences.success')); return redirect()->route('manager.business.show', $business); }
/** * Handle the event. * * @param NewAppointmentWasBooked $event * * @return void */ public function handle(NewAppointmentWasBooked $event) { logger()->info('Handle NewAppointmentWasBooked.SendBookingNotification()'); $code = $event->appointment->code; $date = $event->appointment->start_at->toDateString(); $businessName = $event->appointment->business->name; Notifynder::category('appointment.reserve')->from('App\\Models\\User', $event->user->id)->to('App\\Models\\Business', $event->appointment->business->id)->url('http://localhost')->extra(compact('businessName', 'code', 'date'))->send(); ///////////////// // Send emails // ///////////////// // Mail to User $params = ['user' => $event->user, 'appointment' => $event->appointment]; $header = ['name' => $event->user->name, 'email' => $event->user->email]; $this->transmail->locale($event->appointment->business->locale)->template('appointments.user._new')->subject('user.appointment.reserved.subject')->send($header, $params); // Mail to Owner $params = ['user' => $event->appointment->business->owner(), 'appointment' => $event->appointment]; $header = ['name' => $event->appointment->business->owner()->name, 'email' => $event->appointment->business->owner()->email]; $this->transmail->locale($event->appointment->business->locale)->template('appointments.manager._new')->subject('manager.appointment.reserved.subject')->send($header, $params); }
public function updateAssignmentBidders($assignmentId) { $data = Input::get('data'); $bidders = $data['bidders']; DB::delete('delete from bidder_assignment where assignment_id = ?', [$assignmentId]); foreach ($bidders as $bidder) { DB::insert('insert into bidder_assignment (assignment_id, bidder_id) values (?, ?)', [$assignmentId, $bidder]); Notifynder::category('expert.new_assignment')->from('18')->to('19')->url('available-assignments')->send(); } return $this->respondWithItem($this->model()->findorFail($assignmentId)); }
/** * Attempt an action over an indicated Appointment. * * @param User $user * @param Appointment $appointment * @param string $action * * @throws Exception * * @return App\Models\Appointment */ public function requestAction(User $user, Appointment $appointment, $action) { switch ($action) { case 'annulate': $appointment->doAnnulate(); break; case 'confirm': $appointment->doConfirm(); break; case 'serve': $appointment->doServe(); break; default: // Ignore Invalid Action logger()->warning('Invalid Action request'); throw new \Exception('Invalid Action Request'); break; } // REFACTOR: $this->notify(notificationCategory, user, business, extraArgs) $date = $appointment->date; $code = $appointment->code; Notifynder::category('appointment.' . $action)->from('App\\Models\\User', $user->id)->to('App\\Models\\Business', $appointment->business->id)->url('http://localhost')->extra(compact('code', 'action', 'date'))->send(); return $appointment->fresh(); }
/** * store Business * * @param BusinessFormRequest $request Business form Request * @return Response Redirect */ public function store(BusinessFormRequest $request) { $this->log->info('Manager\\BusinessController@store'); // Search Existing $existingBusiness = Business::withTrashed()->where(['slug' => $request->input('slug')])->first(); // If found if ($existingBusiness !== null) { $this->log->info("Manager\\BusinessController@store: Found existing businessId:{$existingBusiness->id}"); // If owned, restore if (auth()->user()->isOwner($existingBusiness)) { $this->log->info("Manager\\BusinessController@store: Restoring owned businessId:{$existingBusiness->id}"); $existingBusiness->restore(); Flash::success(trans('manager.businesses.msg.store.restored_trashed')); return redirect()->route('manager.business.service.create', $existingBusiness); } # If not owned, return message $this->log->info("Manager\\BusinessController@store: Already taken businessId:{$existingBusiness->id}"); Flash::error(trans('manager.businesses.msg.store.business_already_exists')); return redirect()->route('manager.business.index'); } // Register new Business $business = new Business($request->all()); $category = Category::find($request->get('category')); $business->strategy = $category->strategy; $business->category()->associate($category); $business->save(); auth()->user()->businesses()->attach($business); auth()->user()->save(); // Generate local notification $business_name = $business->name; Notifynder::category('user.registeredBusiness')->from('App\\User', auth()->user()->id)->to('App\\Business', $business->id)->url('http://localhost')->extra(compact('business_name'))->send(); // Redirect success Flash::success(trans('manager.businesses.msg.store.success')); return redirect()->route('manager.business.service.create', $business); }
public function addToFavorites(Request $request) { $agent = Agent::find($request->get('agent')); $user_sender_id = Auth::user()->id; $user_receiver_id = $agent->user->id; if ($user_sender_id == $user_receiver_id) { return Redirect::back()->with('warn_message', 'Cannot favorite your own post'); } FavoriteAgent::create(['user_id' => $user_sender_id, 'agent_id' => $agent->id]); Notifynder::category('user.favorite')->from($user_sender_id)->to($user_receiver_id)->url('http://homestead.app/agents/' . $agent->id)->send(); return Redirect::back(); }
public function notify() { Notifynder::category(Input::get('category'))->from(Input::get('fromId'))->to(Input::get('toId'))->url(Input::get('url'))->send(); return $this->respondWithArray(['status_code' => 200]); }