/** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function index() { $clientId = $this->userRepository->find(Auth::user()->id)->client->id; return view('costumer.orders.index', ['orders' => $this->orderRepository->scopeQuery(function ($q) use($clientId) { return $q->where('client_id', '=', $clientId); })->paginate(5), 'list_status' => ['Pendente', 'A caminho', 'Entregue'], 'row_class' => ['danger', 'warning', 'success']]); }
/** * @param Request $request * @param $id * * @return \Illuminate\Http\RedirectResponse */ public function update(Request $request, $id) { try { $this->orderRepository->update($request->all(), $id); } catch (\Exception $e) { die($e->getMessage()); } return redirect()->route('admin.orders.index'); }
/** * @param array $where * @param Request $request * * @return bool|string */ public function update(array $where, Request $request) { try { if ($request->method() === 'PATCH') { $dataRequest = $request->all(); $key = array_keys($dataRequest)[0]; $value = $dataRequest[$key]; $order = $this->orderRepository->findWhere($where)->first(); return $order ? $order->update([$key => $value]) : false; } } catch (\Exception $e) { return $e->getMessage(); } return false; }
/** * Display the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function show($id) { return $this->orderRepository->with(['coupon', 'items.product.category'])->find($id); }
/** * Display the specified resource. * * @param $orderId * * @return mixed */ public function show($orderId) { $deliverymanId = $this->authorizer->getResourceOwnerId(); return $this->orderRepository->with(['coupon', 'client', 'items.product.category'])->findWhere(['id' => $orderId, 'user_deliveryman_id' => $deliverymanId]); }