public function update($id, Request $request)
 {
     $this->validate($request, $this->rules['update']);
     $detail = $this->orderDetailRepo->update($id, $request->all());
     $total = $this->orderRepo->total($detail->order_id);
     session()->flash('message', trans('messages.update_success'));
     return redirect()->back();
 }
 /**
  * @param $inventory
  */
 private function autoOrder($inventory)
 {
     if ($inventory->stock < $inventory->order_detail->product->point_order) {
         $search = $this->detailRepo->newQuery()->leftJoin('orders', 'order_details.order_id', '=', 'orders.id')->where('order_details.product_id', '=', $inventory->order_detail->product->id)->whereIn('orders.order_status_id', [1, 2, 3])->get();
         if ($search->count() < 1) {
             $newOrder = $this->orderRepo->create(['manager_id' => Auth::user()->id, 'provider_id' => rand(2, 5), 'priority' => 'Alta', 'role_id' => '']);
             $orderDetail = $this->detailRepo->create(['order_id' => $newOrder->id, 'product_id' => $inventory->order_detail->product->id, 'lot' => $inventory->order_detail->product->point_order]);
             $news = $this->notificationRepo->sistemNew($newOrder);
         }
     }
 }