-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Gc command to delete old images, Clear command to delete all images
- Loading branch information
Bradie Tilley
committed
Jan 30, 2020
1 parent
c187f9c
commit 0ea3bb5
Showing
3 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace ABWebDevelopers\ImageResize\Commands; | ||
|
||
use ABWebDevelopers\ImageResize\Classes\Resizer; | ||
use ABWebDevelopers\ImageResize\Models\Settings; | ||
use Carbon\Carbon; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Str; | ||
|
||
class ImageResizeGc extends Command | ||
{ | ||
protected $name = 'imageresize:gc'; | ||
|
||
protected $description = 'Garbage collect all old resized images.'; | ||
|
||
public function handle() | ||
{ | ||
$minAge = Carbon::now()->modify('-' . Settings::getAgeToDelete()); | ||
|
||
$deleted = Resizer::clearFiles($minAge); | ||
|
||
$this->info('Successfully deleted ' . $deleted . ' ' . Str::plural('file', $deleted)); | ||
} | ||
} |