| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public function handle() |
||
| 16 | { |
||
| 17 | $anomalies = 0; |
||
| 18 | foreach (Invoice::all() as $invoice) { |
||
| 19 | // get enrollments |
||
| 20 | $enrollments = $invoice->enrollments->pluck('id')->toArray(); |
||
| 21 | $realEnrollments = $invoice->invoiceDetails()->where('product_type', Enrollment::class)->get()->pluck('product_id')->toArray(); |
||
| 22 | |||
| 23 | if (count(array_diff($enrollments, $realEnrollments)) > 0) { |
||
| 24 | $anomalies++; |
||
| 25 | echo "\ninvoice ".$invoice->id.' is linked to enrollments '.implode(' - ', $enrollments).'and really has '.implode(' - ', $realEnrollments); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | echo $anomalies.' anomalies detected'; |
||
| 29 | } |
||
| 31 |