public function edit($id, OrderService $orderService)
 {
     $order = $this->orderRepository->find($id);
     $statusList = $orderService->statusList();
     $deliverers = $orderService->deliverersList();
     return view('delivery.orders.edit', compact('order', 'statusList', 'deliverers'));
 }
 public function index()
 {
     $clientId = $this->userRepository->find(Auth::user()->id)->client->id;
     $orders = $this->orderRepository->scopeQuery(function ($query) use($clientId) {
         return $query->where('client_id', '=', $clientId);
     })->paginate(5);
     return view('customer.order.index', compact('orders'));
 }
 public function updateStatus(Request $request, $id)
 {
     $id_deliveryman = Authorizer::getResourceOwnerId();
     $order = $this->orderService->updateStatus($id, $id_deliveryman, $request->get('status'));
     if ($order) {
         return $this->orderRepository->find($order->id);
     }
     abort(400, 'Order não encontrada');
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $deliverymanId = Authorizer::getResourceOwnerId();
     // ISSO ------------
     //        $order = $this->orderRepository->with(['items', 'coupon'])->find($id);
     //        $order->items->each(function($item) {
     //            $item->product;
     //        });
     // OU ISSO ------------
     $order = $this->orderRepository->skipPresenter(false)->getByIdAndDeliveryman($id, $deliverymanId);
     return $order;
 }
 public function updateStatus($id, $deliverymanId, $status)
 {
     // para retornar o objeto a ser atualizado
     $order = $this->orderRepository->getByIdAndDeliveryman($id, $deliverymanId);
     if ($order instanceof Order) {
         $order->status = $status;
         $order->save();
         // para retornar o modelo do presenter do objeto para o client
         $order = $this->orderRepository->skipPresenter(false)->getByIdAndDeliveryman($id, $deliverymanId);
         return $order;
     }
     return false;
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     /* tudo retirado após o transformer e presenter
             // ISSO ------------
     //        $order = $this->orderRepository->with(['items', 'coupon'])->find($id);
     //        $order->items->each(function($item) {
     //            $item->product;
     //        });
             // OU ISSO ------------
             $order = $this->orderRepository->with(['items.product.category', 'coupon'])->find($id);
              */
     return $this->orderRepository->skipPresenter(false)->with($this->with)->find($id);
     return $order;
 }
Example #7
0
 public function updateStatus($id, $deliveryman, $status)
 {
     $order = $this->orderRepository->getByIdAndDeliveryman($id, $deliveryman)->first();
     if ($order) {
         $order->status = $status;
         $order->save();
         return $order;
     }
     abort(400, 'Order not fund');
 }
 public function show($id)
 {
     //['client','items.product','cupom','deliveryman']
     $idUser = Authorizer::getResourceOwnerId();
     return $this->orderRepository->skipPresenter(false)->with($this->whith)->findWhere(['client_id' => $idUser, 'id' => $id]);
 }