| Conditions | 3 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 36 | public function fire() |
||
| 37 | { |
||
| 38 | $numberOfDays = (int)$this->option('days'); |
||
| 39 | $numberOfDays = $numberOfDays <= 0 ? 1 : $numberOfDays; |
||
| 40 | |||
| 41 | $minDate = Carbon::now()->subDays( $numberOfDays ); |
||
| 42 | |||
| 43 | // get all the images that were removed at least $numberOfDays ago. |
||
| 44 | $counter = -1; |
||
| 45 | foreach( Image::where('deleted_at', '<=', $minDate )->withTrashed()->cursor() as $counter => $deletedImage ) |
||
| 46 | { |
||
| 47 | // Destroy image. |
||
| 48 | $this->imageService->destroyImage( $deletedImage ); |
||
| 49 | $this->info("Image #$deletedImage->id was destroyed from disk and database."); |
||
| 50 | } |
||
| 51 | |||
| 52 | $counter++; |
||
| 53 | |||
| 54 | $this->info("A total amount of $counter images were destroyed."); |
||
| 55 | } |
||
| 57 | } |