public function add($id)
 {
     $settings = Setting::findOrFail(1);
     $details = OrderDetail::where('order_id', $id)->get();
     foreach ($details as $detail) {
         $profit = $settings->profit * $detail->retail_cost / 100;
         $sale_price = $detail->retail_cost + $profit;
         $this->getModel()->create(['order_detail_id' => $detail->id, 'sale_price' => $sale_price, 'stock' => $detail->lot]);
     }
     return true;
 }
 public function total($id)
 {
     $setting = Setting::findOrFail(1);
     $bill = $this->findOrFail($id);
     $subTotal = $bill->details()->sum('total');
     $iva = $setting->iva * $subTotal / 100;
     $total = $subTotal + $iva;
     $bill->iva = $iva;
     $bill->sub_total = $subTotal;
     $bill->total = $total;
     $bill->save();
     return $bill;
 }