コード例 #1
0
 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;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Setting::create(['id' => 1, 'name' => 'Farmacia Salud Integral', 'company_name' => 'Farmacia Salud Integral', 'address' => 'Área metropolitana del municipio los Cocos', 'phone' => '54606633', 'nit' => '6158063-1', 'iva' => 12, 'profit' => 20]);
 }
コード例 #4
0
 public function setting()
 {
     return $this->belongsTo(Setting::getClass());
 }