/** * Display PHP info output. * * @return string */ public function getPhpInfo() { ob_start(); phpinfo(); $info = ob_get_contents(); ob_get_clean(); return $this->webUi->view('staff.dashboard.info', compact('info')); }
/** * Display the "Christmas Cards" landing page. * * @return \Illuminate\Contracts\View\View */ public function christmasCardsAction() { return $this->webUi->view('customer.landing.christmas-cards', ['products' => $this->tagResource->where('name', '=', 'Christmas')->with(['products' => function ($query) { /* @var Product $query */ $query->inStock(); $query->with(['images', 'options', 'options.images', 'options.stockItems']); }])->first()->products]); }
/** * @param TelegramMessageRequest $request * * @return JsonResponse */ public function store(TelegramMessageRequest $request) { $content = ['chat_id' => StaffTelegramGroup::id(), 'text' => sprintf('(%s) %s', App::environment(), $request->text())]; try { $message = $this->telegram->sendMessage($content); $this->webUi->successMessage("Sent message `{$message->getMessageId()}` to staff"); } catch (\Exception $e) { $this->webUi->errorMessage(sprintf('Failed to send message to staff: %s (%s)', $e->getMessage(), json_encode($content))); } return $this->webUi->redirect('telegram.index'); }
/** * @param RemoveFromBasketRequest $request * * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException * @throws \Exception * * @return \Illuminate\Http\RedirectResponse */ public function removeBasketItemAction(RemoveFromBasketRequest $request) { if (!$this->clerk->basket()->getItem($request->basketItemId())->id) { throw new BadRequestHttpException(sprintf('Basket does not contain any item with id `%s`.', $request->basketItemId())); } /** @var $item */ $item = $this->clerk->removeBasketItem($request->basketItemId()); $this->webUi->successMessage(sprintf('1 × <strong>%s (%s)</strong> %s', $item->productOption->product->name, $item->productOption->label, ' was removed from your basket.')); Analytics::trackEvent('basket', 'remove', $request->basketItemId()); return $this->webUi->redirect('sales.customer.basket'); }
/** * @param int $id * @param string $slug * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * * @return View|RedirectResponse */ public function viewCategory(int $id, string $slug) { /** @var Category $category */ $category = $this->category->findOrFail(Category::privateId($id)); if ($category->slug() !== $slug) { return $this->webUi->redirect('categories.view', [$category->id, $category->slug()]); } $tree = $category->getDescendantsAndSelf()->load(['products' => function ($query) { /* @var Product $query */ $query->with(Product::standardRelations()); }]); return $this->webUi->view('customer.category.view', compact('category', 'tree')); }
/** * @param int $offerId * @param string $slug * * @throws ModelNotFoundException * * @return View|RedirectResponse */ public function view(int $offerId, string $slug) { /** @var Offer $offer */ $offer = Offer::findOrFail($offerId); if ($offer->slug() !== $slug) { return $this->webUi->redirect('offer.show', [$offerId, $offer->slug()]); } $products = Product::whereHas('offers', function ($query) use($offer) { /* @var Builder $query */ $query->where('id', '=', $offer->id); })->with(Product::standardRelations())->paginate(); return $this->webUi->view('sales::offer.view', compact('offer', 'products')); }
/** * @param int $id * @param Request $request * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * * @return \Illuminate\Http\RedirectResponse */ public function putCategoryParent(int $id, Request $request) { /** @var Category $category */ $category = $this->category->findOrFail($id); if ((int) $request->get('parent-id') === -1) { $category->makeRoot(); $this->webUi->successMessage("Made `{$category->name}` a root-level category."); return $this->webUi->redirect('categories.index'); } /** @var Category $parent */ $parent = $this->category->findOrFail($request->get('parent-id')); $category->makeChildOf($parent); $this->webUi->successMessage("Made `{$category->name}` a child of `{$parent->name}`."); return $this->webUi->redirect('categories.index'); }
/** * @param StripePaymentRequest $request * * @throws \Exception * * @return string */ public function payAction(StripePaymentRequest $request) { try { /** @var Order $order */ $order = $this->checkout->pay($request->stripeToken()); } catch (Card $e) { Log::warning(sprintf('Stripe | mess: %s | code: %s | stripe: %s | param: %s', $e->getMessage(), $e->getDeclineCode(), $e->getStripeCode(), $e->getStripeParam())); $this->webUi->errorMessage("Sorry, the card payment was not successful: {$e->getMessage()}"); if (isset($order)) { $order->deAllocate(); } return $this->webUi->redirect('sales.customer.checkout.choose-payment'); } catch (Exception $e) { Log::error($e->getMessage()); $this->webUi->errorMessage('Sorry, something went wrong during payment. Please contact us.'); return $this->webUi->redirect('sales.customer.checkout.choose-payment'); } $this->trackOrder($order); $this->webUi->successMessage('Thank you; your order is confirmed.'); return $this->webUi->redirect('sales.customer.order.view', [$order->publicId()]); }
/** * @param ProductOption $option * * @return \Illuminate\Http\RedirectResponse */ private function redirectToOptionProduct(ProductOption $option) { return $this->webUi->redirect('products.show', [$option->product->sku]); }
/** * @return RedirectResponse */ private function redirectToTagsIndex() : RedirectResponse { return $this->webUi->redirect('tags.index'); }
/** * @return \Illuminate\Http\RedirectResponse */ private function redirectToImagesIndex() { return $this->webUi->redirect('catalogue.staff.products.images.index'); }
/** * @param string $sku * * @return \Illuminate\Http\RedirectResponse */ private function redirectToShowProduct(string $sku) : RedirectResponse { return $this->webUi->redirect('products.show', ['sku' => $sku]); }
/** * @return RedirectResponse */ private function failure() { $this->webUi->errorMessage('Something went wrong whilst setting up the PayPal payment. You have not been charged. Please try again.'); return $this->webUi->redirect('sales.customer.checkout.choose-payment'); }
/** * @param Product $product * * @return \Illuminate\Http\RedirectResponse */ private function redirectToShowProduct(Product $product) { return $this->webUi->redirect('products.show', [$product->sku]); }
/** * @param string $sku * @param SetPriceRequest $setPriceRequest * * @return \Illuminate\Http\RedirectResponse */ public function setProductPrice(string $sku, SetPriceRequest $setPriceRequest) { $this->productRepository->setPriceBySku($sku, $setPriceRequest->get('units'), $setPriceRequest->get('subunits')); return $this->webUi->redirect('products.show', [$sku]); }
/** * @throws \BadMethodCallException * * @return \Illuminate\Http\RedirectResponse */ public function clearProductCache() { $this->view->clearAll(); $this->webUi->successMessage('Product cache was cleared.'); return $this->webUi->redirect('products.index'); }
/** * @param SearchRequest $request * * @return \Illuminate\Contracts\View\View */ public function searchAction(SearchRequest $request) { return $this->webUi->view('customer.product.search', ['query' => $request->searchQuery(), 'products' => $this->productResource->search($request->searchQuery())->paginate(self::PAGE_SIZE)]); }
/** * @param $name * @param array $bindData * * @return View */ private function buildView($name, array $bindData = []) : View { return $this->webUi->view("sales::staff.orders.{$name}", $bindData); }
/** * @return \Illuminate\Contracts\View\View */ public function choosePaymentAction() { return $this->webUi->view('customer.checkout.choose-payment', ['basket' => $this->checkoutAssistant->basket(), 'progress' => 50, 'stripeNonce' => random_int(0, PHP_INT_MAX)]); }
/** * @param int $orderId * * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * * @return string */ public function viewAction(int $orderId) { /** @var Order $order */ $order = $this->orderResource->with(['orderItems.basketItem.productOption.product', 'address'])->findOrFail($this->optimus->decode($orderId)); return $this->webUi->view('customer.orders.view', compact('order')); }