Init
This commit is contained in:
37
app/Console/Commands/TemporaryClear.php
Normal file
37
app/Console/Commands/TemporaryClear.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\TemporaryUpload;
|
||||
use Illuminate\Console\Command;
|
||||
use Storage;
|
||||
|
||||
class TemporaryClear extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'temporary:clear';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Temporary uploads clear';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$uploads = TemporaryUpload::where('created_at', '<', now()->subHour())->get();
|
||||
|
||||
foreach ($uploads as $upload) {
|
||||
Storage::disk('public')->delete($upload->path);
|
||||
$upload->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user