| Conditions | 4 | 
| Paths | 4 | 
| Total Lines | 21 | 
| Code Lines | 13 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 26 | public function handle() : void  | 
            ||
| 27 |     { | 
            ||
| 28 |         foreach (Enrollment::all() as $enrollment) { | 
            ||
| 29 |             $payments = DB::table('payments')->where('enrollment_id', $enrollment->id)->get(); | 
            ||
| 30 | |||
| 31 |             if ($payments->count() > 0) { | 
            ||
| 32 |                 foreach ($payments as $payment) { | 
            ||
| 33 | // generate an Invoice  | 
            ||
| 34 | $invoice = Invoice::create([  | 
            ||
| 35 | 'invoice_type_id' => 1,  | 
            ||
| 36 | 'receipt_number' => $payment->receipt_id,  | 
            ||
| 37 | 'total_price' => $payment->value / 100,  | 
            ||
| 38 | 'date' => $payment->created_at,  | 
            ||
| 39 | 'created_at' => $payment->created_at,  | 
            ||
| 40 | ]);  | 
            ||
| 41 | |||
| 42 | $invoice->setNumber();  | 
            ||
| 43 | |||
| 44 | $enrollment->invoices()->attach($invoice);  | 
            ||
| 45 | |||
| 46 |                     DB::table('payments')->where('id', $payment->id)->update(['invoice_id' => $invoice->id]); | 
            ||
| 47 | }  | 
            ||
| 52 |