Example #1
0
 public function invoiceRepair($id, Request $req, Invoice $invoice)
 {
     $repair = File::where('id', $id)->with('repair.details.article', 'repair.device.modele.brand', 'repair.device.modele.category', 'client')->first();
     $num = $id * 12;
     $invoice = Invoice::firstOrNew(['file_id' => $id]);
     if (!isset($invoice['id'])) {
         $invoice['created_at'] = date("d-m-Y");
         $invoice['number'] = $num;
         $invoice->save();
     }
     if ($req['_action'] == "sendmail") {
         $response = $invoice->sendRepairMail($invoice, $repair);
         return $response;
     }
     return view('/files/invoice-repair', ['repair' => $repair, 'invoice' => $invoice]);
 }