/** * Show Business Notifications. * * @param Business $business Business to show * * @return Response Rendered view for Business show */ public function show(Business $business) { logger()->info(__METHOD__); logger()->info(sprintf('businessId:%s', $business->id)); $this->authorize('manage', $business); // BEGIN $notifications = Notifynder::entity(Business::class)->getAll($business->id); return view('manager.businesses.notifications', compact('business', 'notifications')); }
/** * 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')); }
/** * Run the database seeds. * * @return void */ public function run() { Notifynder::addCategory('user.visitedShowroom', '{from.username} visited showroom'); Notifynder::addCategory('user.registeredBusiness', '{from.username} registered :business'); Notifynder::addCategory('user.subscribedBusiness', '{from.username} subscribed to business'); Notifynder::addCategory('user.checkingVacancies', '{from.username} checks vacancies'); Notifynder::addCategory('user.updatedBusinessPreferences', '{from.username} updated :business preferences'); Notifynder::addCategory('user.importedContacts', '{from.username} imported :count contacts'); Notifynder::addCategory('appointment.reserve', '{from.username} made a reservation for :business'); Notifynder::addCategory('appointment.annulate', '{from.username} annulated appointment'); Notifynder::addCategory('appointment.confirm', '{from.username} confirmed appointment'); Notifynder::addCategory('appointment.serve', '{from.username} served appointment'); }
/** * 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')); }); }
/** * 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); }
/** * 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); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { session()->put('count', Notifynder::countNotRead(session()->get('VKusr'))); return $next($request); }
/** * 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(); }
/** * show Business. * * @param Business $business Business to show * @param BusinessFormRequest $request Business form Request * * @return Response Rendered view for Business show */ public function show(Business $business) { logger()->info(__METHOD__); logger()->info(sprintf('businessId:%s', $business->id)); $this->authorize('manage', $business); // BEGIN session()->set('selected.business', $business); $notifications = Notifynder::entity(Business::class)->getNotRead($business->id, 20); Notifynder::entity(Business::class)->readAll($business->id); $this->time->timezone($business->timezone); // Build Dashboard Report $dashboard['appointments_active_today'] = $business->bookings()->active()->ofDate($this->time->today())->get()->count(); $dashboard['appointments_canceled_today'] = $business->bookings()->canceled()->ofDate($this->time->today())->get()->count(); $dashboard['appointments_active_tomorrow'] = $business->bookings()->active()->ofDate($this->time->tomorrow())->get()->count(); $dashboard['appointments_active_total'] = $business->bookings()->active()->get()->count(); $dashboard['appointments_served_total'] = $business->bookings()->served()->get()->count(); $dashboard['appointments_total'] = $business->bookings()->get()->count(); $dashboard['contacts_registered'] = $business->contacts()->count(); $dashboard['contacts_subscribed'] = $business->contacts()->whereNotNull('user_id')->count(); $time = $this->time->toTimeString(); return view('manager.businesses.show', compact('business', 'notifications', 'dashboard', 'time')); }
/** * 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 accept(Request $request) { $id = $request->input('id'); if (isset($id)) { $book = Book::find($id); if ($book == null) { return redirect('/'); } else { if ($book->current_owner == session()->get('VKusr')) { Notifynder::readOne($request->input('n')); $book->current_owner = $request->input('user'); $book->taken = 1; $book->save(); HistoryController::create(session()->get('VKusr'), $book->current_owner, $book->id); } } } return redirect('/myBooks'); }
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 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)); }
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]); }