/** * @return string */ public function getPushableChannel() { if (property_exists(get_class($this), 'pushableChannel')) { return $this->pushableChannel; } if ($this instanceof ModelAccountResource) { return pusher_account_channel(); } return pusher_system_channel(); }
/** * @param GammaNotification $notification * @param Account $account * @param Brand $brand * @param Category $category * @param Pusher $pusher * @return int */ protected function cancelInverseNotifications(GammaNotification $notification, Account $account, Brand $brand, Category $category, Pusher $pusher) { $notifications = $notification->newQueryWithoutScopes()->where('account_id', $account->id)->where('brand_id', $brand->id)->where('category_id', $category->id)->whereNull('product_id')->notBeingProcessed()->get(); $counter = 0; foreach ($notifications as $notification) { $pusher->trigger(pusher_account_channel(), 'gamma.gamma_notification.denied', $notification->toArray()); $notification->delete(); ++$counter; } return $counter; }
/** * @param Request $request * @param AccountManager $accounts * @param AccountRepositoryInterface $repository * @param Pusher $pusher */ public function locale(Request $request, AccountManager $accounts, AccountRepositoryInterface $repository, Pusher $pusher) { $account = $accounts->account(); if ($request->get('activated')) { $account->locales()->attach($request->get('id')); } else { $account->locales()->detach($request->get('id')); } //bust cache $repository->updated(); //broadcast event $pusher->trigger(pusher_account_channel(), 'system.hard-reload', []); }
/** * @param Request $request * @param Module $module * @param AccountManager $manager * @param Pusher $pusher */ public function toggle(Request $request, Module $module, AccountManager $manager, Pusher $pusher) { $module = $module->findOrFail($request->get('id')); $account = $manager->account(); if ($request->get('activated')) { //attach module $account->modules()->attach($module->id); //broadcast event $pusher->trigger(pusher_account_channel(), 'system.hard-reload', []); } else { //detach module $account->modules()->detach($module->id); //broadcast event $pusher->trigger(pusher_account_channel(), 'system.hard-reload', []); } }
/** * @param GammaSelection $gamma * @param Pusher $pusher * @param CatalogRepositoryInterface $catalog * @param ProductSelection $productGamma * @param GammaNotification $notifications * @throws \Exception */ public function handle(GammaSelection $gamma, Pusher $pusher, CatalogRepositoryInterface $catalog, ProductSelection $productGamma, GammaNotification $notifications) { //we should put all products online within this scope. $notification = $this->notification; switch ($this->notification->type) { case 'activate': $this->insertNewGammaSelection($gamma, $notification); $this->notifyWithinScope($catalog, $productGamma, 'activate'); $this->cancelNotifications($notifications, 'deactivate'); break; case 'deactivate': $this->notifyWithinScope($catalog, $productGamma, 'deactivate'); $this->cancelNotifications($notifications, 'activate'); break; } $pusher->trigger(pusher_account_channel(), 'gamma.gamma_notification.confirmed', $this->notification->toArray()); $this->notification->delete(); }
/** * @param GammaNotification $notification * @param Pusher $pusher */ public function handle(GammaNotification $notification, Pusher $pusher) { if ($this->beingProcessed($notification, $this->account, $this->brand, $this->category)) { $message = 'this gamma detail is still being processed'; abort(400, $message, ['statustext' => $message]); } //did we already have a brand activation notification for this brand? //then we simply delete it. //if not, we'create one $existing = $this->findExistingCombination($notification, $this->account, $this->brand, $this->category); if ($existing) { $pusher->trigger(pusher_account_channel(), 'gamma.gamma_notification.denied', $existing->toArray()); $existing->delete(); } else { $instance = $notification->newInstance(['account_id' => $this->account->id, 'category_id' => $this->category->id, 'brand_id' => $this->brand->id, 'type' => 'deactivate']); $instance->save(); } }
/** * @param Pusher $pusher * @throws \Exception */ protected function finish(Pusher $pusher) { $pusher->trigger(pusher_account_channel(), 'gamma.gamma_notification.confirmed', $this->notification->toArray()); $this->notification->delete(); }
/** * @return string */ function pusher_system_channel() { // return 'private-system'; return pusher_account_channel(); }
public function testReturnsAccountChannelWhenDealingWithAnAccountResource() { $instance = new DummyCanPushAccountResource(); $this->assertSame(pusher_account_channel(), $instance->getPushableChannel()); }